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
20 21 22 |
# File 'lib/toy/attributes.rb', line 20 def attribute(key, type, = {}) Attribute.new(self, key, type, ) end |
#attribute?(key) ⇒ Boolean
24 25 26 |
# File 'lib/toy/attributes.rb', line 24 def attribute?(key) attributes.has_key?(key.to_s) end |
#attributes ⇒ Object
12 13 14 |
# File 'lib/toy/attributes.rb', line 12 def attributes @attributes ||= {} end |
#defaulted_attributes ⇒ Object
16 17 18 |
# File 'lib/toy/attributes.rb', line 16 def defaulted_attributes attributes.values.select(&:default?) end |