Module: RemoteAssociation::Base::ClassMethods
- Defined in:
- lib/remote_association.rb
Instance Method Summary collapse
-
#activeresource_relations ⇒ Object
Returns settings for relations to ActiveResource models.
-
#add_activeresource_relation(name, options) ⇒ Object
Adds settings of relation to ActiveResource model.
Methods included from RemoteAssociation::BelongsToRemote
Methods included from HasManyRemote
Methods included from HasOneRemote
Instance Method Details
#activeresource_relations ⇒ Object
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, ) activeresource_relations[name] = end |