Sha256: 0fd1bc0aceaca32a4263390cd51d9542bbd2dab8ae80a2e90962b96a3ff50653

Contents?: true

Size: 839 Bytes

Versions: 4

Compression:

Stored size: 839 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
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
quandl_data-1.1.2 lib/quandl/data/enumerator.rb
quandl_data-1.1.1 lib/quandl/data/enumerator.rb
quandl_data-1.1.0 lib/quandl/data/enumerator.rb
quandl_data-1.0.0 lib/quandl/data/enumerator.rb