Module: Jat::Plugins::SimpleApi::Map::ClassMethods

Included in:
Jat::Plugins::SimpleApi::Map
Defined in:
lib/jat/plugins/simple_api/lib/map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#jat_classObject

Returns the Jat class that this Map class is namespaced under.



9
10
11
# File 'lib/jat/plugins/simple_api/lib/map.rb', line 9

def jat_class
  @jat_class
end

Instance Method Details

#call(context) ⇒ Object

Returns structure like

key1 => { key11 => {, key12 => { ... } },
key2 => { key21 => {}, key22 => { ... } },

}



23
24
25
26
27
28
# File 'lib/jat/plugins/simple_api/lib/map.rb', line 23

def call(context)
  exposed = context[:exposed]&.to_sym || :default
  fields = context[:fields]

  construct_map(exposed, fields)
end

#inspectObject

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/simple_api/lib/map.rb', line 14

def inspect
  "#{jat_class.inspect}::Map"
end