Class: Ambition::Adapters::ActiveRecord::Base
- Inherits:
-
Object
- Object
- Ambition::Adapters::ActiveRecord::Base
- Includes:
- ActiveRecord::ConnectionAdapters::Quoting
- Defined in:
- lib/ambition/adapters/active_record/base.rb
Instance Method Summary collapse
- #dbadapter_name ⇒ Object
- #quote_column_name(value) ⇒ Object
- #sanitize(value) ⇒ Object
- #statement(*args) ⇒ Object
Instance Method Details
#dbadapter_name ⇒ Object
40 41 42 43 44 |
# File 'lib/ambition/adapters/active_record/base.rb', line 40 def dbadapter_name ::ActiveRecord::Base.connection.adapter_name rescue ::ActiveRecord::ConnectionNotEstablished 'Abstract' end |
#quote_column_name(value) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ambition/adapters/active_record/base.rb', line 32 def quote_column_name(value) if owner.connected? ::ActiveRecord::Base.connection.quote_column_name(value) else value.to_s end end |
#sanitize(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ambition/adapters/active_record/base.rb', line 9 def sanitize(value) if value.is_a? Array return value.map { |v| sanitize(v) }.join(', ') end case value when true '1' when false '0' when Regexp "'#{value.source}'" else if owner.connected? ::ActiveRecord::Base.connection.quote(value) else quote(value) end end rescue "'#{value}'" end |
#statement(*args) ⇒ Object
46 47 48 49 |
# File 'lib/ambition/adapters/active_record/base.rb', line 46 def statement(*args) @statement_instance ||= DatabaseStatements.const_get(dbadapter_name).new @statement_instance.send(*args) end |