Sha256: 6341a68dd55ea783dc8f64afce12f93b3d0df92c6b316e3d8b0ae3a8dd81630f

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

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

module Quandl
module Client

class Source

  include ScopeBuilder::Model
  
  scope_builder_for :search
  
  search_scope :query
  search_scope :page, ->(p){ where( page: p.to_i )}
  search_scope :code, ->(c){ where( code: c.to_s.upcase )}
  
  search_helper :all, ->{ connection.where(attributes).fetch }
  search_helper :connection, -> { self.class.parent }

  search_scope.class_eval do
    delegate *Array.forwardable_methods, to: :all
  end
  
  # ORM
  include Her::Model
  use_api Client.her_api
  attributes :code, :datasets_count, :description, :name, :host
  
  def datasets
    Dataset.source_code(code)
  end
  
  def id
    'show'
  end
  
end

end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
quandl_client-0.0.4 lib/quandl/client/models/source.rb
quandl_client-0.0.3 lib/quandl/client/models/source.rb
quandl_client-0.0.2 lib/quandl/client/models/source.rb
quandl_client-0.0.1 lib/quandl/client/models/source.rb