# File lib/spyke/associations/belongs_to.rb, line 21 def primary_key_value parent.try(foreign_key) end
class Spyke::Associations::BelongsTo
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Spyke::Associations::Association::new
# 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
Public Instance Methods
find_one()
click to toggle source
Calls superclass method
# File lib/spyke/associations/belongs_to.rb, line 10 def find_one return unless fetchable? super end
Private Instance Methods
fetchable?()
click to toggle source
# File lib/spyke/associations/belongs_to.rb, line 17 def fetchable? (primary_key_value || embedded_data).present? end
primary_key_value()
click to toggle source