class Userlist::Push::ResourceCollection

Attributes

collection[R]
config[R]
owner[R]
relationship[R]

Public Class Methods

new(collection, relationship, owner, config = Userlist.config) click to toggle source
# File lib/userlist/push/resource_collection.rb, line 8
def initialize(collection, relationship, owner, config = Userlist.config)
  @collection = Array(collection)
  @relationship = relationship
  @owner = owner
  @config = config
end

Public Instance Methods

each() { |from_payload| ... } click to toggle source
# File lib/userlist/push/resource_collection.rb, line 15
def each
  collection.each do |resource|
    resource[inverse] = owner if inverse && resource.is_a?(Hash)

    yield type.from_payload(resource, config)
  end
end
inverse() click to toggle source
# File lib/userlist/push/resource_collection.rb, line 27
def inverse
  relationship[:inverse]
end
type() click to toggle source
# File lib/userlist/push/resource_collection.rb, line 23
def type
  Object.const_get(relationship[:type])
end