Sha256: 9a889084896f6321e03d5ab771a00c1feaa9d6468dd3dff6d941d2e0d47eb166
Contents?: true
Size: 1013 Bytes
Versions: 2
Compression:
Stored size: 1013 Bytes
Contents
module Quandl::Data::Enumerator extend ActiveSupport::Concern included do delegate *Array.forwardable_methods, to: :data_array delegate :to_json, :as_json, to: :data_array attr_accessor :pristine_data end def initialize(*args) self.pristine_data = args.first self.attributes = args.extract_options! end def data_array @data_array ||= parse( pristine_data ) end def data_array=(data) @data_array = parse(data) end def data_array? @data_array.present? end def attributes @attributes ||= {} end def attributes=(attrs) assign_attributes(attrs) attributes end # mass assignment protection def assign_attributes(attrs) attrs.each do |name, value| self.send("#{name}=", value) if self.respond_to?("#{name}=") end end protected def parse(data) data = data.to_a if data.respond_to?(:to_a) && data.is_a?(Quandl::Data) data = Quandl::Operation::Parse.perform( data ) data end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quandl_data-1.2.1 | lib/quandl/data/enumerator.rb |
quandl_data-1.2.0 | lib/quandl/data/enumerator.rb |