Module: RemoteAssociation::Base::ClassMethods

Includes:
RemoteAssociation::BelongsToRemote, HasManyRemote, HasOneRemote
Defined in:
lib/remote_association.rb

Instance Method Summary collapse

Methods included from RemoteAssociation::BelongsToRemote

#belongs_to_remote

Methods included from HasManyRemote

#has_many_remote

Methods included from HasOneRemote

#has_one_remote

Instance Method Details

#activeresource_relationsObject

Returns settings for relations to ActiveResource models.

Examples

Author.activeresource_relations #=>

{
  profile: {class_name: "Profile", foreign_key: "author_id"},
  badges: {class_name: "Badge", foreign_key: "author_id"}
}


55
56
57
# File 'lib/remote_association.rb', line 55

def activeresource_relations
  @activeresource_relations ||= {}
end

#add_activeresource_relation(name, options) ⇒ Object

Adds settings of relation to ActiveResource model.

Parameters

  • name a Symbol, representing name of association

  • options a Hash, contains :class_name and :foreign_key settings

Examples

Author.add_activeresource_relation(:profile, “Profile”, foreign_key: “author_id”)



42
43
44
# File 'lib/remote_association.rb', line 42

def add_activeresource_relation(name, options)
  activeresource_relations[name] = options
end