Module: Fortnox::API::Mapper::ToJSON

Included in:
Base
Defined in:
lib/fortnox/api/mappers/base/to_json.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/fortnox/api/mappers/base/to_json.rb', line 7

def self.included(base)
  base.send :extend, ClassMethods

  base.send :private_class_method,
            :convert_hash_keys_to_json_format,
            :convert_key_to_json,
            :default_key_to_json_transform,
            :sanitise
end

Instance Method Details

#entity_to_hash(entity, keys_to_filter) ⇒ Object



49
50
51
52
53
# File 'lib/fortnox/api/mappers/base/to_json.rb', line 49

def entity_to_hash(entity, keys_to_filter)
  entity_json_hash = Registry[mapper_name_for(entity)]
                     .call(entity, keys_to_filter)
  wrap_entity_json_hash(entity_json_hash)
end

#wrap_entity_json_hash(entity_json_hash) ⇒ Object



55
56
57
# File 'lib/fortnox/api/mappers/base/to_json.rb', line 55

def wrap_entity_json_hash(entity_json_hash)
  { self.class::JSON_ENTITY_WRAPPER => entity_json_hash }
end