class MmJsonClient::GenericType
The base class for dynamically generated types.
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/mm_json_client/generic_type.rb, line 4 def initialize(attributes = {}) @data = {} attributes.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end
property(attribute)
click to toggle source
# File lib/mm_json_client/generic_type.rb, line 12 def property(attribute) class_eval do define_method(attribute) do @data[attribute] end define_method("#{attribute}=") do |value| @data[attribute] = value end end end
Public Instance Methods
deep_copy()
click to toggle source
# File lib/mm_json_client/generic_type.rb, line 33 def deep_copy Marshal.load(Marshal.dump(self)) end
set_properties()
click to toggle source
# File lib/mm_json_client/generic_type.rb, line 25 def set_properties @data.keys.sort.map(&:to_s) end
to_h()
click to toggle source
# File lib/mm_json_client/generic_type.rb, line 29 def to_h {}.merge(@data) end