Module: Her::Model::Attributes
- Defined in:
- lib/quandl/her/collection.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.initialize_collection(klass, parsed_data = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/quandl/her/collection.rb', line 18 def self.initialize_collection(klass, parsed_data={}) arr = klass.extract_array(parsed_data) arr = [] unless arr.is_a?(Array) collection_data = arr.map do |item_data| resource = klass.new(klass.parse(item_data)) resource.run_callbacks :find resource end Her::Collection.new(collection_data, parsed_data[:metadata], parsed_data[:errors]) end |
Instance Method Details
#initialize(attributes = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/quandl/her/collection.rb', line 4 def initialize(attributes={}) if attributes.is_a?(Integer) attributes = { id: attributes } end attributes ||= {} @metadata = attributes.delete(:_metadata) || {} @response_errors = attributes.delete(:_errors) || {} @destroyed = attributes.delete(:_destroyed) || false attributes = self.class.default_scope.apply_to(attributes) assign_attributes(attributes) run_callbacks :initialize end |