Module: Jat::Plugins::JsonApi::Map::InstanceMethods

Included in:
Jat::Plugins::JsonApi::Map
Defined in:
lib/jat/plugins/json_api/lib/map.rb

Constant Summary collapse

EXPOSED_TYPES =
{all: :all, default: :default, none: :none}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exposedObject (readonly)

Returns the value of attribute exposed.



35
36
37
# File 'lib/jat/plugins/json_api/lib/map.rb', line 35

def exposed
  @exposed
end

#fieldsObject (readonly)

Returns the value of attribute fields.



35
36
37
# File 'lib/jat/plugins/json_api/lib/map.rb', line 35

def fields
  @fields
end

#includesObject (readonly)

Returns the value of attribute includes.



35
36
37
# File 'lib/jat/plugins/json_api/lib/map.rb', line 35

def includes
  @includes
end

#jat_classObject (readonly)

Returns the value of attribute jat_class.



35
36
37
# File 'lib/jat/plugins/json_api/lib/map.rb', line 35

def jat_class
  @jat_class
end

Instance Method Details

#initialize(exposed, fields, includes) ⇒ Object



39
40
41
42
43
44
# File 'lib/jat/plugins/json_api/lib/map.rb', line 39

def initialize(exposed, fields, includes)
  @jat_class = self.class.jat_class
  @exposed = EXPOSED_TYPES.fetch(exposed)
  @fields = fields
  @includes = includes
end

#to_hObject



46
47
48
49
50
# File 'lib/jat/plugins/json_api/lib/map.rb', line 46

def to_h
  map = {}
  append_map(map, jat_class)
  map
end