Sha256: de1d544ef44ce1978029330565772af09cc87e54991eb8732760a08bec3cdfe8
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
# ApiClient::Collection handle a collection of objects class ApiClient::Collection < Array # Initialize a collection of objects based on attributes. # # @param [String] attributes the array of attributes. # @param [Class] klass The class to instantiate the objects. # @return [Collection] the collection of objects. def initialize(attributes, klass) @klass = klass if attributes.instance_of?(Array) attributes.each do |attr| self << @klass.new(attr) end else self << @klass.new(attributes) end end # Update the collection of objects based on the new attributes. # # @param [String] attributes the array of attributes. # @return [Collection] the collection of objects. def update(attributes) self.clear if attributes.instance_of?(Array) attributes.each do |attr| self << @klass.new(attr) end else self << @klass.new(attributes) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
api-client-2.5.0 | lib/api-client/collection.rb |
api-client-2.5.0.rc1 | lib/api-client/collection.rb |