module Fortnox::API::Mapper::ToJSON
Public Class Methods
included(base)
click to toggle source
# 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
Public Instance Methods
entity_to_hash(entity, keys_to_filter)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
mapper_name_for(value)
click to toggle source
# File lib/fortnox/api/mappers/base/to_json.rb, line 61 def mapper_name_for(value) value.class.name.split('::').last.downcase.to_sym end