Sha256: 43546e4c4ee9a423212c09bef58a7e56166a080cce746f44fa35546146b5c44b
Contents?: true
Size: 1.1 KB
Versions: 8
Compression:
Stored size: 1.1 KB
Contents
module JFoundry::V2::ModelMagic module HasSummary def has_summary(actions = {}) # # def summary # define_method(:summary) do @client.base.get("v2", plural_object_name, @guid, "summary", :accept => :json) end # # def summarize! # define_method(:summarize!) do |*args| body, _ = args body ||= summary body.each do |key, val| if act = actions[key] instance_exec(val, &act) elsif self.class.attributes[key] self.send(:"#{key}=", val) elsif self.class.to_many_relations[key] singular = key.to_s.sub(/s$/, "").to_sym vals = val.collect do |sub| obj = @client.send(singular, sub[:guid], true) obj.summarize! sub obj end self.send(:"#{key}=", vals) elsif self.class.to_one_relations[key] obj = @client.send(key, val[:guid], true) obj.summarize! val self.send(:"#{key}=", obj) end end nil end end end end
Version data entries
8 entries across 8 versions & 1 rubygems