Sha256: 8822bd2f9b8ac0956ae62ee6f97ba1214b47e5585cc107c8503c17b73c13fc17

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

require 'quandl/client/models/dataset/searchable'
require 'quandl/client/models/dataset/properties'

module Quandl
module Client

class Sheet

  include ScopeBuilder::Model
  
  scope_builder_for :search
  
  search_scope :query, :page, :url_title
  search_helper :all, ->{ connection.where(attributes).fetch.to_a }
  search_helper :connection, -> { self.class.parent }

  search_scope.class_eval do
    delegate *Array.forwardable_methods, to: :all
  end
  
  class << self
    
    def find_by_url_title(title)
      where( url_title: title ).find('show')
    end
    
  end
  
  # ORM
  include Her::Model
  use_api Client.her_api
  attributes :title, :url_title, :content
  
  def html
    @html ||= @attributes['html'] || Sheet.find(self.url_title).instance_variable_get('@attributes')['data']
  end
  
  def id
    'show'
  end
  
end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quandl_client-0.0.1 lib/quandl/client/models/sheet.rb