Class: Dbee::Providers::ActiveRecordProvider
- Inherits:
-
Object
- Object
- Dbee::Providers::ActiveRecordProvider
- Defined in:
- lib/dbee/providers/active_record_provider.rb,
lib/dbee/providers/active_record_provider/version.rb,
lib/dbee/providers/active_record_provider/safe_alias_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder.rb,
lib/dbee/providers/active_record_provider/obfuscated_alias_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/order_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/where_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/select_maker.rb,
lib/dbee/providers/active_record_provider/expression_builder/constraint_maker.rb
Overview
Provider which leverages ActiveRecord and Arel for generating SQL.
Defined Under Namespace
Classes: ExpressionBuilder, ObfuscatedAliasMaker, SafeAliasMaker
Constant Summary collapse
- VERSION =
'2.0.1'
Instance Attribute Summary collapse
-
#column_alias_maker ⇒ Object
readonly
Returns the value of attribute column_alias_maker.
-
#readable ⇒ Object
readonly
Returns the value of attribute readable.
-
#table_alias_maker ⇒ Object
readonly
Returns the value of attribute table_alias_maker.
Instance Method Summary collapse
-
#initialize(readable: true, table_prefix: DEFAULT_TABLE_PREFIX, column_prefix: DEFAULT_COLUMN_PREFIX) ⇒ ActiveRecordProvider
constructor
A new instance of ActiveRecordProvider.
- #sql(model, query) ⇒ Object
Constructor Details
#initialize(readable: true, table_prefix: DEFAULT_TABLE_PREFIX, column_prefix: DEFAULT_COLUMN_PREFIX) ⇒ ActiveRecordProvider
Returns a new instance of ActiveRecordProvider.
28 29 30 31 32 33 34 35 36 |
# File 'lib/dbee/providers/active_record_provider.rb', line 28 def initialize( readable: true, table_prefix: DEFAULT_TABLE_PREFIX, column_prefix: DEFAULT_COLUMN_PREFIX ) @readable = readable @table_alias_maker = alias_maker(table_prefix) @column_alias_maker = alias_maker(column_prefix) end |
Instance Attribute Details
#column_alias_maker ⇒ Object (readonly)
Returns the value of attribute column_alias_maker.
26 27 28 |
# File 'lib/dbee/providers/active_record_provider.rb', line 26 def column_alias_maker @column_alias_maker end |
#readable ⇒ Object (readonly)
Returns the value of attribute readable.
26 27 28 |
# File 'lib/dbee/providers/active_record_provider.rb', line 26 def readable @readable end |
#table_alias_maker ⇒ Object (readonly)
Returns the value of attribute table_alias_maker.
26 27 28 |
# File 'lib/dbee/providers/active_record_provider.rb', line 26 def table_alias_maker @table_alias_maker end |
Instance Method Details
#sql(model, query) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dbee/providers/active_record_provider.rb', line 38 def sql(model, query) ExpressionBuilder.new( model, table_alias_maker, column_alias_maker ).add(query).to_sql end |