Sha256: ce662a934ec295a7e35be200f6b87350298260252cc6af33702b3798743a4215
Contents?: true
Size: 901 Bytes
Versions: 11
Compression:
Stored size: 901 Bytes
Contents
module Ecoportal module API module Common class BaseModel attr_reader :doc def initialize(doc = {}) @doc = doc @original_doc = JSON.parse(doc.to_json) end def print puts JSON.pretty_generate(as_json) self end def as_json doc end def to_json(*args) doc.to_json(*args) end def as_update new_doc = as_json Common::HashDiff.diff(new_doc, @original_doc) end def self.passthrough(*methods, to:) methods.each do |method| method = method.to_s define_method method do send(to)[method] end define_method "#{method}=" do |value| send(to)[method] = value end end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems