Method: LibGems::Specification.attribute

Defined in:
lib/libgems/specification.rb

.attribute(name, default = nil) ⇒ Object

Specifies the name and default for a specification attribute, and creates a reader and writer method like Module#attr_accessor.

The reader method returns the default if the value hasn’t been set.



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/libgems/specification.rb', line 158

def self.attribute(name, default=nil)
  ivar_name = "@#{name}".intern
  if default.nil? then
    @@nil_attributes << ivar_name
  else
    @@non_nil_attributes << [ivar_name, default]
  end

  @@attributes << [name, default]
  @@default_value[name] = default
  attr_accessor(name)
end