Class: EagerGroup::Definition
- Inherits:
-
Object
- Object
- EagerGroup::Definition
- Defined in:
- lib/eager_group/definition.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #aggregation_function ⇒ Object
- #default_value ⇒ Object
-
#initialize(association, aggregate_function, column_name, scope) ⇒ Definition
constructor
A new instance of Definition.
- #need_load_object ⇒ Object
Constructor Details
#initialize(association, aggregate_function, column_name, scope) ⇒ Definition
Returns a new instance of Definition.
7 8 9 10 11 12 |
# File 'lib/eager_group/definition.rb', line 7 def initialize(association, aggregate_function, column_name, scope) @association = association @aggregate_function = aggregate_function @column_name = column_name @scope = scope end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
5 6 7 |
# File 'lib/eager_group/definition.rb', line 5 def association @association end |
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
5 6 7 |
# File 'lib/eager_group/definition.rb', line 5 def column_name @column_name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
5 6 7 |
# File 'lib/eager_group/definition.rb', line 5 def scope @scope end |
Instance Method Details
#aggregation_function ⇒ Object
14 15 16 17 18 19 |
# File 'lib/eager_group/definition.rb', line 14 def aggregation_function return :maximum if @aggregate_function.to_sym == :last_object return :minimum if @aggregate_function.to_sym == :first_object @aggregate_function end |
#default_value ⇒ Object
25 26 27 |
# File 'lib/eager_group/definition.rb', line 25 def default_value %i[first_object last_object].include?(@aggregate_function.to_sym) ? nil : 0 end |
#need_load_object ⇒ Object
21 22 23 |
# File 'lib/eager_group/definition.rb', line 21 def need_load_object %i[first_object last_object].include?(@aggregate_function.to_sym) end |