Module: BlindDate::ActiveRecord::ConnectionAdapters::AbstractAdapter::ClassMethods
- Defined in:
- lib/blind_date/active_record/connection_adapters/abstract_adapter.rb
Instance Method Summary collapse
-
#adapter_name ⇒ Object
Returns name of adapter suitable for loading related classes Should have same output as instance method of same name TODO: Kludgy: maybe upstream could provide a class method?.
-
#date_add(style, date, interval, unit = 'SECOND', diff = false) ⇒ Object
Performs arithmetic on string is an SQL-escaped date/time/datetime or returns a date/time/datetime.
Instance Method Details
#adapter_name ⇒ Object
Returns name of adapter suitable for loading related classes Should have same output as instance method of same name TODO: Kludgy: maybe upstream could provide a class method?
26 27 28 |
# File 'lib/blind_date/active_record/connection_adapters/abstract_adapter.rb', line 26 def adapter_name to_s.underscore[ /\/([^\/]+)_adapter$/, 1 ].gsub( '_', '' ) end |
#date_add(style, date, interval, unit = 'SECOND', diff = false) ⇒ Object
Performs arithmetic on string is an SQL-escaped date/time/datetime or returns a date/time/datetime
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/blind_date/active_record/connection_adapters/abstract_adapter.rb', line 8 def date_add( style, date, interval, unit = 'SECOND', diff = false ) case interval when ActiveSupport::Duration interval.parts.inject( date ) do |memo, span| date_add_sql_without_operator style, memo, span.last, span.first.to_s.singularize.upcase, diff end when String date_add_sql style, date, interval, unit.to_s.singularize.upcase, ( diff ? '-' : '+' ) when Numeric date_add_sql_without_operator style, date, interval, unit.to_s.singularize.upcase, diff else raise ArgumentError end end |