Class: Spyke::Associations::BelongsTo
- Inherits:
-
Association
- Object
- Relation
- Association
- Spyke::Associations::BelongsTo
- Defined in:
- lib/spyke/associations/belongs_to.rb
Instance Attribute Summary
Attributes inherited from Association
Attributes inherited from Relation
Instance Method Summary collapse
- #find_one ⇒ Object
-
#initialize(*args) ⇒ BelongsTo
constructor
A new instance of BelongsTo.
Methods inherited from Association
#assign_nested_attributes, #create, #load, #new
Methods inherited from Relation
#each, #find, #find_some, #uri, #where, #with, #with_fallback
Constructor Details
#initialize(*args) ⇒ BelongsTo
Returns a new instance of BelongsTo.
4 5 6 7 8 |
# File 'lib/spyke/associations/belongs_to.rb', line 4 def initialize(*args) super @options.reverse_merge!(uri: "#{@name.to_s.pluralize}/:#{primary_key}", foreign_key: "#{klass.model_name.element}_id") @params[primary_key] = primary_key_value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spyke::Relation
Instance Method Details
#find_one ⇒ Object
10 11 12 13 |
# File 'lib/spyke/associations/belongs_to.rb', line 10 def find_one return unless fetchable? super end |