module JSONAPI::Ruby::Deserializer::Parser

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/jsonapi-ruby-deserializer/parser.rb, line 22
def method_missing(method, *args, &block)
  if args.empty?
    super
  else
    field = method[0...-1]
    instance_variable_set("@#{field}", *args)
    self.class.send(:attr_accessor, field.to_sym)
  end
end
parse!(data) click to toggle source
# File lib/jsonapi-ruby-deserializer/parser.rb, line 7
def parse!(data)
  data.each do |field, value|
    instance_variable_set("@#{field}", value)
    self.class.send(:attr_accessor, field.to_sym)
  end
end
to_h() click to toggle source
# File lib/jsonapi-ruby-deserializer/parser.rb, line 14
def to_h
  {}.tap do |h|
    self.instance_variables.each do |variable|
      h.merge!(variable.to_s[1..-1] => instance_variable_get(variable))
    end
  end
end