Class: Groupdate::Adapters::BaseAdapter
- Inherits:
-
Object
- Object
- Groupdate::Adapters::BaseAdapter
- Defined in:
- lib/groupdate/adapters/base_adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#day_start ⇒ Object
readonly
Returns the value of attribute day_start.
-
#n_seconds ⇒ Object
readonly
Returns the value of attribute n_seconds.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
-
#week_start ⇒ Object
readonly
Returns the value of attribute week_start.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(relation, column:, period:, time_zone:, time_range:, week_start:, day_start:, n_seconds:, adapter_name: nil) ⇒ BaseAdapter
constructor
A new instance of BaseAdapter.
Constructor Details
#initialize(relation, column:, period:, time_zone:, time_range:, week_start:, day_start:, n_seconds:, adapter_name: nil) ⇒ BaseAdapter
Returns a new instance of BaseAdapter.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 6 def initialize(relation, column:, period:, time_zone:, time_range:, week_start:, day_start:, n_seconds:, adapter_name: nil) @relation = relation @column = column @period = period @time_zone = time_zone @time_range = time_range @week_start = week_start @day_start = day_start @n_seconds = n_seconds @adapter_name = adapter_name if ActiveRecord::VERSION::MAJOR >= 7 if ActiveRecord.default_timezone == :local raise Groupdate::Error, "ActiveRecord.default_timezone must be :utc to use Groupdate" end else if relation.default_timezone == :local raise Groupdate::Error, "ActiveRecord::Base.default_timezone must be :utc to use Groupdate" end end end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
4 5 6 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 4 def column @column end |
#day_start ⇒ Object (readonly)
Returns the value of attribute day_start.
4 5 6 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 4 def day_start @day_start end |
#n_seconds ⇒ Object (readonly)
Returns the value of attribute n_seconds.
4 5 6 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 4 def n_seconds @n_seconds end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
4 5 6 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 4 def period @period end |
#week_start ⇒ Object (readonly)
Returns the value of attribute week_start.
4 5 6 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 4 def week_start @week_start end |
Instance Method Details
#generate ⇒ Object
28 29 30 |
# File 'lib/groupdate/adapters/base_adapter.rb', line 28 def generate @relation.group(group_clause).where(*where_clause) end |