Module: Toy::Attributes::ClassMethods

Defined in:
lib/toy/attributes.rb

Instance Method Summary collapse

Instance Method Details

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



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

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

#attribute?(key) ⇒ Boolean

Returns:



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

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

#attributesObject



12
13
14
# File 'lib/toy/attributes.rb', line 12

def attributes
  @attributes ||= {}
end

#defaulted_attributesObject



16
17
18
# File 'lib/toy/attributes.rb', line 16

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