Module: Toy::Attributes::ClassMethods
- Defined in:
- lib/toy/attributes.rb
Instance Method Summary collapse
- #attribute(key, type, options = {}) ⇒ Object
- #attribute?(key) ⇒ Boolean
- #attributes ⇒ Object
- #defaulted_attributes ⇒ Object
Instance Method Details
#attribute(key, type, options = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/toy/attributes.rb', line 28 def attribute(key, type, = {}) attribute = Attribute.new(self, key, type, ) define_attribute_methods [attribute.name] attribute end |
#attribute?(key) ⇒ Boolean
34 35 36 |
# File 'lib/toy/attributes.rb', line 34 def attribute?(key) attributes.has_key?(key.to_s) end |
#attributes ⇒ Object
20 21 22 |
# File 'lib/toy/attributes.rb', line 20 def attributes @attributes ||= {} end |
#defaulted_attributes ⇒ Object
24 25 26 |
# File 'lib/toy/attributes.rb', line 24 def defaulted_attributes attributes.values.select(&:default?) end |