Class: ToyModel::AttributesCollection
- Inherits:
-
Object
- Object
- ToyModel::AttributesCollection
- Defined in:
- lib/toy-model/attributes_collection.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(klass, *args) ⇒ AttributesCollection
constructor
A new instance of AttributesCollection.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(klass, *args) ⇒ AttributesCollection
Returns a new instance of AttributesCollection.
6 7 8 9 |
# File 'lib/toy-model/attributes_collection.rb', line 6 def initialize klass, *args @attributes = [] args.each { |attr| @attributes << klass.attribute(attr) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
11 12 13 14 |
# File 'lib/toy-model/attributes_collection.rb', line 11 def method_missing(m, *args, &block) @attributes.each { |attr| attr.send m, *args } self end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/toy-model/attributes_collection.rb', line 4 def attributes @attributes end |