Class: Spyke::Associations::HasOne

Inherits:
Association show all
Defined in:
lib/spyke/associations/has_one.rb

Instance Attribute Summary

Attributes inherited from Association

#name, #parent

Attributes inherited from Relation

#klass, #params

Instance Method Summary collapse

Methods inherited from Association

#assign_nested_attributes, #create, #load, #new

Methods inherited from Relation

#each, #find, #find_one, #find_some, #uri, #where, #with, #with_fallback

Constructor Details

#initialize(*args) ⇒ HasOne

Returns a new instance of HasOne.



4
5
6
7
8
# File 'lib/spyke/associations/has_one.rb', line 4

def initialize(*args)
  super
  @options.reverse_merge!(uri: "#{parent.class.model_name.plural}/:#{foreign_key}/#{@name}")
  @params[foreign_key] = parent.id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spyke::Relation