Sha256: 1e9fa6f0e3e3ff18186c00a5d3b31c394b35c8379cb84d200b6851f724fae9fd
Contents?: true
Size: 576 Bytes
Versions: 18
Compression:
Stored size: 576 Bytes
Contents
module Spyke module Associations class BelongsTo < Association 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 def find_one return unless fetchable? super end private def fetchable? (primary_key_value || embedded_data).present? end def primary_key_value parent.try(foreign_key) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems