Sha256: 57b574a2b23d2e1bdecf82a2ee8df4fd97f1660304420d29f5c3d1d3fe1fc66c
Contents?: true
Size: 782 Bytes
Versions: 21
Compression:
Stored size: 782 Bytes
Contents
module ApiResource module Associations class BelongsToRemoteObjectProxy < SingleObjectProxy attr_reader :foreign_key # sets some defaults for the foreign key name for this association def self.define_association_as_attribute(klass, assoc_name, opts = {}) opts["foreign_key"] = self.foreign_key_name(assoc_name) super(klass, assoc_name, opts) end # constructor def initialize(klass, owner, opts = {}) super @foreign_key = opts["foreign_key"] || @klass.to_s.foreign_key # now if we have an owner and a foreign key, we set # the data up to load if key = owner.send(self.foreign_key) self.remote_path = self.klass.element_path(key) end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems