Sha256: 36f14cafeb64200b3c06e2fa894010b76ef0de1c3161c3db31c4f105382aeb0c
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
module ChartMogul module Concerns module Entries def self.included(base) base.extend ClassMethods base.instance_eval do if @resource_root_key.nil? @resource_root_key = :entries end readonly_attr @resource_root_key, default: [] include API::Actions::All include Enumerable def_delegators @resource_root_key, :each, :[], :<<, :size, :length, :empty?, :first resource_root_key = @resource_root_key.to_s base.send :define_method, "set_" + resource_root_key do |entries| objects = entries.map do |entity| self.class.get_entry_class.new_from_json(entity) end self.instance_variable_set "@#{resource_root_key}", objects end end end module ClassMethods def set_entry_class(klass) instance_variable_set("@entry_class", klass) end def get_entry_class instance_variable_get("@entry_class") end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
chartmogul-ruby-1.1.3 | lib/chartmogul/concerns/entries.rb |
chartmogul-ruby-1.1.1 | lib/chartmogul/concerns/entries.rb |
chartmogul-ruby-1.1.0 | lib/chartmogul/concerns/entries.rb |