class Besepa::Collection
Attributes
current_page[RW]
items[RW]
pages[RW]
pagination[R]
per_page[RW]
total[RW]
Public Class Methods
new(response, klass)
click to toggle source
# File lib/besepa/collection.rb, line 7 def initialize(response, klass) @pagination = false @items = [] process_response(response, klass) end
Public Instance Methods
each(&block)
click to toggle source
# File lib/besepa/collection.rb, line 13 def each &block @items.each{|item| block.call(item)} end
Private Instance Methods
process_response(response, klass)
click to toggle source
# File lib/besepa/collection.rb, line 21 def process_response(response, klass) if response['pagination'] @pagination = true self.per_page = response['pagination']['per_page'] self.current_page = response['pagination']['current'] self.total = response['pagination']['count'] self.pages = response['pagination']['pages'] end response['response'].each do |c| @items << klass.new(c) end end