Module: Attrable Private

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#attr_predicate(*attrs) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



6
7
8
9
10
11
12
# File 'attrable.rb', line 6

def attr_predicate(*attrs)
  attrs.each do |attr|
    define_method attr do
      instance_variable_get("@#{attr.to_s.sub(/\?$/, "")}") == true
    end
  end
end

#attr_rw(*attrs) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



15
16
17
18
19
20
21
# File 'attrable.rb', line 15

def attr_rw(*attrs)
  attrs.each do |attr|
    define_method attr do |val = nil|
      val.nil? ? instance_variable_get(:"@#{attr}") : instance_variable_set(:"@#{attr}", val)
    end
  end
end