class ApiMapper::Serializer

Public Class Methods

new(model) click to toggle source
# File lib/api_mapper/client.rb, line 124
def initialize(model)
  @model = model
end

Public Instance Methods

call() click to toggle source
# File lib/api_mapper/client.rb, line 128
def call
  serialize.to_json if @model
end

Private Instance Methods

attributes() click to toggle source
# File lib/api_mapper/client.rb, line 140
def attributes
  @model.attributes.select { |_, value| !value.nil? }
end
serialize() click to toggle source
# File lib/api_mapper/client.rb, line 134
def serialize
  attributes.reduce({}) do |response, (key, value)|
    response.merge(key => value)
  end
end