Class: Groupdate::RelationBuilder
- Inherits:
-
Object
- Object
- Groupdate::RelationBuilder
- Defined in:
- lib/groupdate/relation_builder.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#day_start ⇒ Object
readonly
Returns the value of attribute day_start.
-
#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:) ⇒ RelationBuilder
constructor
A new instance of RelationBuilder.
Constructor Details
#initialize(relation, column:, period:, time_zone:, time_range:, week_start:, day_start:) ⇒ RelationBuilder
Returns a new instance of RelationBuilder.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/groupdate/relation_builder.rb', line 5 def initialize(relation, column:, period:, time_zone:, time_range:, week_start:, day_start:) @relation = relation @column = resolve_column(relation, column) @period = period @time_zone = time_zone @time_range = time_range @week_start = week_start @day_start = day_start if relation.default_timezone == :local raise Groupdate::Error, "ActiveRecord::Base.default_timezone must be :utc to use Groupdate" end end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
3 4 5 |
# File 'lib/groupdate/relation_builder.rb', line 3 def column @column end |
#day_start ⇒ Object (readonly)
Returns the value of attribute day_start.
3 4 5 |
# File 'lib/groupdate/relation_builder.rb', line 3 def day_start @day_start end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
3 4 5 |
# File 'lib/groupdate/relation_builder.rb', line 3 def period @period end |
#week_start ⇒ Object (readonly)
Returns the value of attribute week_start.
3 4 5 |
# File 'lib/groupdate/relation_builder.rb', line 3 def week_start @week_start end |
Instance Method Details
#generate ⇒ Object
19 20 21 |
# File 'lib/groupdate/relation_builder.rb', line 19 def generate @relation.group(group_clause).where(*where_clause) end |