Class: ActiveRecordQuery::Base

Inherits:
Object
  • Object
show all
Includes:
Conditionable, Featureable, Groupable, Havingable, Identifiable, Joinable, Limitable, Offsetable, Orderable, Selectable
Defined in:
lib/activerecord-query.rb

Overview

The base class collects all the activerecord query features and the execute method processes all the features. The api user must inherit from this class in order to build a new query definition.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Conditionable

#build_conditions

Methods included from Havingable

#build_having

Methods included from Offsetable

#build_offset

Methods included from Groupable

#build_group_by

Methods included from Joinable

#build_joins, #build_left_outer_joins

Methods included from Limitable

#build_limit

Methods included from Orderable

#build_order

Methods included from Selectable

#build_select

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



32
33
34
# File 'lib/activerecord-query.rb', line 32

def initialize(options = {})
  @options = options
end

Class Method Details

.execute(options = {}) ⇒ Object



27
28
29
# File 'lib/activerecord-query.rb', line 27

def execute(options = {})
  new(options).execute
end

Instance Method Details

#executeObject



36
37
38
39
40
41
42
# File 'lib/activerecord-query.rb', line 36

def execute
  query = resource.all
  self.class._query_features.each do |query_feature|
    query = send(query_feature, query)
  end
  query
end