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
26 27 28 29 30 31 |
# File 'lib/toy/attributes.rb', line 26 def attribute(key, type, = {}) @defaulted_attributes = nil attribute = Attribute.new(self, key, type, ) define_attribute_methods [attribute.name] attribute end |
#attribute?(key) ⇒ Boolean
33 34 35 |
# File 'lib/toy/attributes.rb', line 33 def attribute?(key) attributes.has_key?(key.to_s) end |
#attributes ⇒ Object
18 19 20 |
# File 'lib/toy/attributes.rb', line 18 def attributes @attributes ||= {} end |
#defaulted_attributes ⇒ Object
22 23 24 |
# File 'lib/toy/attributes.rb', line 22 def defaulted_attributes @defaulted_attributes ||= attributes.values.select(&:default?) end |