Module: Encore::Serializer::LinksReflectionIncluder::NotLoaded
- 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
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 37 def self.reflection_belongs_to(object, reflection) reflection_type = reflection.name.to_s.pluralize reflection_id = object.send(reflection.foreign_key).try(:to_s) { href: "/#{reflection_type}/#{reflection_id}", id: reflection_id, type: reflection_type } end |
.reflection_has_many(object, reflection) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 19 def self.reflection_has_many(object, reflection) reflection_type = reflection.name.to_s.pluralize { href: "/#{reflection_type}?#{object.class.name.downcase}_id=#{object.id}", type: reflection_type } end |
.reflection_has_one(object, reflection) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/encore/serializer/links_reflection_includer.rb', line 28 def self.reflection_has_one(object, reflection) reflection_type = reflection.name.to_s { href: "/#{object.class.name.downcase.pluralize}/#{object.id}/#{reflection_type}", type: reflection_type.pluralize } end |