Module: Toy::Attributes::ClassMethods

Defined in:
lib/toy/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(key, type, options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/toy/attributes.rb', line 28

def attribute(key, type, options = {})
  attribute = Attribute.new(self, key, type, options)
  define_attribute_methods [attribute.name]
  attribute
end

#attribute?(key) ⇒ Boolean

Returns:



34
35
36
# File 'lib/toy/attributes.rb', line 34

def attribute?(key)
  attributes.has_key?(key.to_s)
end

#attributesObject



20
21
22
# File 'lib/toy/attributes.rb', line 20

def attributes
  @attributes ||= {}
end

#defaulted_attributesObject



24
25
26
# File 'lib/toy/attributes.rb', line 24

def defaulted_attributes
  attributes.values.select(&:default?)
end