Sha256: adb1b292a6944f722869e881f8ce5ee5a08d9bcd005d13dcbd2affae7b42eb6f

Contents?: true

Size: 868 Bytes

Versions: 7

Compression:

Stored size: 868 Bytes

Contents

module ChartMogul
  module Concerns
    module Entries
      def self.included(base)
        base.extend ClassMethods
        base.send :prepend, InstanceMethods

        base.instance_eval do
          readonly_attr :entries, default: []

          include API::Actions::All

          include Enumerable
          def_delegators :entries, :each, :[], :<<, :size, :length
        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

      module InstanceMethods
        def set_entries(entries_attributes)
          @entries = entries_attributes.map do |entity|
            self.class.get_entry_class.new_from_json(entity)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chartmogul-ruby-1.0.2 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-1.0.1 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-1.0.0 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-0.1.4 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-0.1.3 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-0.1.2 lib/chartmogul/concerns/entries.rb
chartmogul-ruby-0.1.1 lib/chartmogul/concerns/entries.rb