Module: Encore::Serializer::LinksReflectionIncluder::Loaded
- Defined in:
- lib/encore/serializer/links_reflection_includer.rb
Class Method Summary collapse
- .reflection_belongs_to(object, reflection) ⇒ Object
- .reflection_has_many(object, reflection) ⇒ Object
- .reflection_has_one(object, reflection) ⇒ Object
Class Method Details
.reflection_belongs_to(object, reflection) ⇒ Object
5 6 7 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 5 def self.reflection_belongs_to(object, reflection) object.send(reflection.foreign_key).try(:to_s) if object.respond_to?(reflection.foreign_key) end |
.reflection_has_many(object, reflection) ⇒ Object
13 14 15 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 13 def self.reflection_has_many(object, reflection) object.send("#{reflection.name.to_s.singularize}_ids").map(&:to_s) if object.send(reflection.name).loaded? end |
.reflection_has_one(object, reflection) ⇒ Object
9 10 11 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 9 def self.reflection_has_one(object, reflection) object.send(reflection.name).try(:id).try(:to_s) end |