Class: Spyke::Associations::Association
- Defined in:
- lib/spyke/associations/association.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes inherited from Relation
Instance Method Summary collapse
- #assign_nested_attributes(attributes) ⇒ Object
- #create(attributes = {}) ⇒ Object
-
#initialize(klass, parent, name, options = {}) ⇒ Association
constructor
A new instance of Association.
- #load ⇒ Object
- #new(*args) ⇒ Object (also: #build)
Methods inherited from Relation
#each, #find, #find_one, #find_some, #uri, #where, #with, #with_fallback
Constructor Details
#initialize(klass, parent, name, options = {}) ⇒ Association
Returns a new instance of Association.
9 10 11 12 |
# File 'lib/spyke/associations/association.rb', line 9 def initialize(klass, parent, name, = {}) super(klass, ) @parent, @name = parent, name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spyke::Relation
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/spyke/associations/association.rb', line 7 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
7 8 9 |
# File 'lib/spyke/associations/association.rb', line 7 def parent @parent end |
Instance Method Details
#assign_nested_attributes(attributes) ⇒ Object
18 19 20 |
# File 'lib/spyke/associations/association.rb', line 18 def assign_nested_attributes(attributes) update_parent new(attributes) end |
#create(attributes = {}) ⇒ Object
22 23 24 |
# File 'lib/spyke/associations/association.rb', line 22 def create(attributes = {}) add_to_parent super end |
#load ⇒ Object
14 15 16 |
# File 'lib/spyke/associations/association.rb', line 14 def load find_one # Override for plural associations that return an association object end |
#new(*args) ⇒ Object Also known as: build
26 27 28 |
# File 'lib/spyke/associations/association.rb', line 26 def new(*args) add_to_parent super end |