Class: OlapReport::Cube::Level
- Inherits:
-
Object
- Object
- OlapReport::Cube::Level
- Defined in:
- lib/olap_report/cube/level.rb
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#dimension_name ⇒ Object
readonly
Returns the value of attribute dimension_name.
-
#joins ⇒ Object
readonly
Returns the value of attribute joins.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#build_relation(relation) ⇒ Object
Applies necessary select, joins & group_by statements to passed relation.
-
#initialize(dimension, name, options = {}) ⇒ Object
constructor
New level instance initialization.
Constructor Details
#initialize(dimension, name, options = {}) ⇒ Object
New level instance initialization
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/olap_report/cube/level.rb', line 15 def initialize(dimension, name, = {}) raise ArgumentError unless dimension && name raise ArgumentError if [:joins].is_a?(Hash) && [:joins].size > 1 @model = dimension.model @dimension_name = dimension.name @name = name @column_name = [:column] || @name @joins, @type = .values_at(:joins, :type) end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
3 4 5 |
# File 'lib/olap_report/cube/level.rb', line 3 def column_name @column_name end |
#dimension_name ⇒ Object (readonly)
Returns the value of attribute dimension_name.
3 4 5 |
# File 'lib/olap_report/cube/level.rb', line 3 def dimension_name @dimension_name end |
#joins ⇒ Object (readonly)
Returns the value of attribute joins.
3 4 5 |
# File 'lib/olap_report/cube/level.rb', line 3 def joins @joins end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/olap_report/cube/level.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/olap_report/cube/level.rb', line 3 def type @type end |
Instance Method Details
#build_relation(relation) ⇒ Object
Applies necessary select, joins & group_by statements to passed relation
27 28 29 30 31 |
# File 'lib/olap_report/cube/level.rb', line 27 def build_relation(relation) relation.select(column_with_alias(column, name)). joins(joins). group(@group_by || column) end |