class Round::Collection
Attributes
collection[R]
Public Class Methods
new(options = {}, &block)
click to toggle source
Calls superclass method
Round::Base::new
# File lib/round/collection.rb, line 6 def initialize(options = {}, &block) super(options) options.delete(:resource) populate_data(options, &block) end
Public Instance Methods
[](key)
click to toggle source
# File lib/round/collection.rb, line 37 def [](key) if key.is_a?(Fixnum) @collection[key] else @hash[key] end end
add(content)
click to toggle source
# File lib/round/collection.rb, line 28 def add(content) @collection << content @hash[content.hash_identifier] = content end
content_type()
click to toggle source
# File lib/round/collection.rb, line 33 def content_type Round::Base end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
Round::Base#method_missing
# File lib/round/collection.rb, line 45 def method_missing(meth, *args, &block) @collection.send(meth, *args, &block) rescue super end
populate_data(options = {}) { |content| ... }
click to toggle source
# File lib/round/collection.rb, line 12 def populate_data(options = {}, &block) @collection = [] @hash = {} @resource.list.each do |resource| content = self.content_type.new(options.merge(resource: resource, client: @client)) yield content if block self.add(content) end if @resource.list rescue nil end
refresh(options = {})
click to toggle source
# File lib/round/collection.rb, line 22 def refresh(options = {}) @collection = [] populate_data(options) self end