module PagSeguro::Extensions::CollectionObject

Attributes

store[RW]

Public Class Methods

new() click to toggle source
# File lib/pagseguro/extensions/collection_object.rb, line 12
def initialize
  @store = []
end

Public Instance Methods

<<(param) click to toggle source

Adds a new object to the collection.

# File lib/pagseguro/extensions/collection_object.rb, line 21
def <<(param)
  object = ensure_type(collection_type, param)
  @store << object unless include?(object)
end
collection_type() click to toggle source
# File lib/pagseguro/extensions/collection_object.rb, line 16
def collection_type
  PagSeguro.const_get(class_name_singularized)
end

Private Instance Methods

class_name_singularized() click to toggle source
# File lib/pagseguro/extensions/collection_object.rb, line 28
def class_name_singularized
  class_name = self.class.to_s.split('::').last
  class_name[0...-1] if class_name.end_with? 's'
end