Class: ChoronSupport::Queries::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/choron_support/queries/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ Base

Returns a new instance of Base.

Parameters:

  • model_class (ActiveRecord::Base)


5
6
7
8
# File 'lib/choron_support/queries/base.rb', line 5

def initialize(model_class)
  @model_class = model_class
  @records = model_class.try!(:all)
end

Instance Method Details

#callObject

各種このメソッドをオーバーライドしてください

Raises:

  • (NotImplementedError)


11
12
13
14
15
16
# File 'lib/choron_support/queries/base.rb', line 11

def call
  raise NotImplementedError
  # @example 実装例
  #   recordsにはscopeが呼び出された瞬間にチェインされてきたSQL情報が入ったActiveRecord::Relationが入っているため、そのままwhereを繋げていけば良い
  #   records.where(xxx: foo)
end