Module: Postmen::CollectionProxy

Extended by:
Forwardable
Includes:
Enumerable
Included in:
LabelCollection, ManifestCollection, RateCollection, ShipperAccountCollection
Defined in:
lib/postmen/collection_proxy.rb

Overview

This is a mixin used by all collections. For an user perspective, every collection should behave like a simple array of models.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Method called on base object when mixin gets included



44
45
46
47
# File 'lib/postmen/collection_proxy.rb', line 44

def self.included(base)
  base.extend ClassMethods
  base.instance_variable_set('@settings', {})
end

Instance Method Details

#initialize(response) ⇒ Object

Constructor



53
54
55
# File 'lib/postmen/collection_proxy.rb', line 53

def initialize(response)
  @data = response[:data][self.class.key].map { |element| self.class.model.new(element) }
end