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
215 216 217 |
# File 'lib/nube/remote_relation.rb', line 215 def polymorphic_belongs_to(rel, opts={}) self.send("#{rel}_type").constantize.find(self.send("#{rel}_id")) end |
#polymorphic_has_many(rel, opts = {}) ⇒ Object
223 224 225 |
# File 'lib/nube/remote_relation.rb', line 223 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
219 220 221 |
# File 'lib/nube/remote_relation.rb', line 219 def polymorphic_has_one(rel, opts={}) polymorphic_has_many(rel, opts={}).first end |