class Objectification::FromHash
Constants
- IGNORE
Public Class Methods
new(properties = {})
click to toggle source
# File lib/objectification/from_hash.rb, line 9 def initialize(properties = {}) properties.each_pair do |key, value| self.class.method(:attr_accessor).call key instance_variable_set "@#{key}", value end self end
Public Instance Methods
to_h()
click to toggle source
# File lib/objectification/from_hash.rb, line 17 def to_h instance_methods.each_with_object({}) do |instance_method, hash| hash[instance_method] = method(instance_method).call end end
Private Instance Methods
instance_methods()
click to toggle source
# File lib/objectification/from_hash.rb, line 25 def instance_methods ((self.class.instance_methods - self.class.private_methods) - Object.instance_methods) .map(&:to_s) .reject { |m| IGNORE.include? m } .reject { |m| m.start_with? '__' } .reject { |m| m.end_with? '=' } end
types()
click to toggle source
# File lib/objectification/from_hash.rb, line 33 def types to_h.types end