Sha256: 556ab4ec3698c56811852c7eb2d492fe5cf1dd154b5ac32a75391f31f8766cdc
Contents?: true
Size: 971 Bytes
Versions: 5
Compression:
Stored size: 971 Bytes
Contents
class Quandl::Client::Base module Search extend ActiveSupport::Concern module ClassMethods def forwardable_scope_methods @forwardable_scope_methods ||= Array.forwardable_methods.reject{|m| [:find, :fetch].include?(m) } end end included do include ScopeComposer::Model has_scope_composer scope :with_id, ->(value) { where( id: value.to_i )} scope_helper :all, ->{ connection.where(attributes).fetch } scope_helper :connection, -> { self.class.parent } scope.class_eval do delegate *Array.forwardable_methods.reject{|m| [:find, :fetch].include?(m) }, to: :all def fetch_once @fetch_once ||= fetch end def fetch find(attributes[:id]) end def find(id) result = self.class.parent.where(attributes).find(id) result = self.class.parent.new(id: id) if result.nil? result end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems