Module: RemoteRelation
- Extended by:
- ActiveSupport::Concern
- Included in:
- LocalAssociation, RemoteAssociation, RemoteScope
- Defined in:
- lib/nube/remote_relation.rb
Instance Method Summary collapse
- #polymorphic_belongs_to(rel, opts = {}) ⇒ Object
- #polymorphic_has_many(rel, opts = {}) ⇒ Object
- #polymorphic_has_one(rel, opts = {}) ⇒ Object
Instance Method Details
#polymorphic_belongs_to(rel, opts = {}) ⇒ Object
214 215 216 |
# File 'lib/nube/remote_relation.rb', line 214 def polymorphic_belongs_to(rel, opts={}) self.send("#{rel}_type").constantize.find(self.send("#{rel}_id")) end |
#polymorphic_has_many(rel, opts = {}) ⇒ Object
222 223 224 |
# File 'lib/nube/remote_relation.rb', line 222 def polymorphic_has_many(rel, opts={}) self.class.xclass(rel).where("#{opts[:as]}_id" => self.id, "#{opts[:as]}_type" => self.class.to_s) end |
#polymorphic_has_one(rel, opts = {}) ⇒ Object
218 219 220 |
# File 'lib/nube/remote_relation.rb', line 218 def polymorphic_has_one(rel, opts={}) polymorphic_has_many(rel, opts={}).first end |