Sha256: 8f735a840a3c89fef6ed7fea015844741b4fefe02be0a7129ccc44533b41381a

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

module Quandl
class Data
module Attributes
  
  extend ActiveSupport::Concern
  
  included do
    
    include Quandl::Support::Attributes
    
    define_attributes :headers, :pristine_data, :cleaned, :data_array
    
    delegate *Array.forwardable_methods, to: :data_array
    delegate :to_json, :as_json, to: :data_array

    def headers=(value)
      write_attribute(:headers, Array(value).flatten )
    end
    
    def cleaned?
      read_attribute(:cleaned) == true
    end
    
  end
  
  def initialize(*args)
    # passed an instance of quandl data?
    if args.first.kind_of?(Quandl::Data)
      @attributes = args.first.attributes
    elsif args.first.present?
      self.pristine_data = args.first
    end
    valid? unless cleaned?
  end
  
end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quandl_data-1.5.0 lib/quandl/data/attributes.rb
quandl_data-1.4.1 lib/quandl/data/attributes.rb
quandl_data-1.4.0 lib/quandl/data/attributes.rb