class Contactually::Utils
Public Class Methods
method_missing(m, *args)
click to toggle source
Calls superclass method
# File lib/contactually/utils.rb, line 5 def method_missing(m, *args) case m when /^(\w*)_hash_to_objects/ then hash_to_objects($1, *args) when /^build_(\w*)/ then build_object($1, *args) else super(m, *args) end end
respond_to?(m, *args)
click to toggle source
Calls superclass method
# File lib/contactually/utils.rb, line 16 def respond_to?(m, *args) case m when /^(\w*)_hash_to_objects/ then true when /^build_(\w*)/ then true else super(m, *args) end end
Private Class Methods
build_object(type, hash)
click to toggle source
# File lib/contactually/utils.rb, line 37 def build_object(type, hash) representer_class = "Contactually::Representer::#{type.classify}Representer".constantize object_class = "Contactually::#{type.classify}".constantize representer_class.new(object_class.new).from_hash(hash['data']) end
hash_to_objects(type, hash)
click to toggle source
# File lib/contactually/utils.rb, line 29 def hash_to_objects(type, hash) representer_class = "Contactually::Representer::#{type.classify}Representer".constantize object_class = "Contactually::#{type.classify}".constantize hash['data'].inject([]) do |arr, obj| arr << representer_class.new(object_class.new).from_hash(obj) end end