Class: DbDumper::QueryBuilder::Query
- Inherits:
-
Object
- Object
- DbDumper::QueryBuilder::Query
- Defined in:
- lib/db_dumper/query_builder/query.rb
Overview
Wrapper under ActiveRecord::Relation
Instance Attribute Summary collapse
-
#ar ⇒ Object
readonly
Returns the value of attribute ar.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(raw_table, exist_ar = nil) ⇒ Query
constructor
A new instance of Query.
- #joins(*args) ⇒ Object
- #select(*args) ⇒ Object
- #table_name ⇒ Object
- #to_sql ⇒ Object
- #where(*args) ⇒ Object
Constructor Details
Instance Attribute Details
#ar ⇒ Object (readonly)
Returns the value of attribute ar.
8 9 10 |
# File 'lib/db_dumper/query_builder/query.rb', line 8 def ar @ar end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
8 9 10 |
# File 'lib/db_dumper/query_builder/query.rb', line 8 def table @table end |
Instance Method Details
#joins(*args) ⇒ Object
19 20 21 22 |
# File 'lib/db_dumper/query_builder/query.rb', line 19 def joins(*args) raise 'Only simple string for joins supported' unless args.size == 1 && args[0].is_a?(String) self.class.new(table, ar.joins(*args)) end |
#select(*args) ⇒ Object
24 25 26 |
# File 'lib/db_dumper/query_builder/query.rb', line 24 def select(*args) self.class.new(table, ar.select(*args)) end |
#table_name ⇒ Object
28 29 30 |
# File 'lib/db_dumper/query_builder/query.rb', line 28 def table_name table.table_name end |
#to_sql ⇒ Object
32 33 34 |
# File 'lib/db_dumper/query_builder/query.rb', line 32 def to_sql @ar.to_sql end |
#where(*args) ⇒ Object
15 16 17 |
# File 'lib/db_dumper/query_builder/query.rb', line 15 def where(*args) self.class.new(table, ar.where(*args)) end |