Module: Jat::Plugins::JsonApi::Map::ClassMethods
- Included in:
- Jat::Plugins::JsonApi::Map
- Defined in:
- lib/jat/plugins/json_api/lib/map.rb
Instance Attribute Summary collapse
-
#jat_class ⇒ Object
Returns the Jat class that this Map class is namespaced under.
Instance Method Summary collapse
-
#call(context) ⇒ Object
Returns structure like { type1 => { attributes: [attr1, attr2, …], relationships: [rel1, rel2, …] }, type2 => { … } }.
-
#inspect ⇒ Object
Since Map is anonymously subclassed when Jat is subclassed, and then assigned to a constant of the Jat subclass, make inspect reflect the likely name for the class.
Instance Attribute Details
#jat_class ⇒ Object
Returns the Jat class that this Map class is namespaced under.
9 10 11 |
# File 'lib/jat/plugins/json_api/lib/map.rb', line 9 def jat_class @jat_class end |
Instance Method Details
#call(context) ⇒ Object
Returns structure like {
type1 => {
attributes: [attr1, attr2, ...],
relationships: [rel1, rel2, ...]
},
type2 => { ... }
}
26 27 28 29 30 31 32 |
# File 'lib/jat/plugins/json_api/lib/map.rb', line 26 def call(context) exposed = context[:exposed]&.to_sym || :default fields = context[:fields] includes = context[:include] construct_map(exposed, fields, includes) end |
#inspect ⇒ Object
Since Map is anonymously subclassed when Jat is subclassed, and then assigned to a constant of the Jat subclass, make inspect reflect the likely name for the class.
14 15 16 |
# File 'lib/jat/plugins/json_api/lib/map.rb', line 14 def inspect "#{jat_class.inspect}::Map" end |