Class: Saulabs::Reportable::ResultSet

Inherits:
Object
  • Object
show all
Defined in:
lib/saulabs/reportable/result_set.rb

Overview

A result set as it is returned by the report methods. This is basically a subclass of Array that adds two attributes, model_class_name and report_name that store the name of the model and the report the result set was generated from.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array, model_class_name, report_name) ⇒ ResultSet

Initializes a new result set.

Parameters:

  • array (Array)

    the array that is the actual result

  • model_class_name (String)

    the name of the model the result set is based on

  • report_name (String)

    the name of the report the result is based on



36
37
38
39
40
# File 'lib/saulabs/reportable/result_set.rb', line 36

def initialize(array, model_class_name, report_name)
  @results = array
  @model_class_name  = model_class_name
  @report_name = report_name.to_s
end

Instance Attribute Details

#model_class_nameObject (readonly)

the name of the model the result set is based on



15
16
17
# File 'lib/saulabs/reportable/result_set.rb', line 15

def model_class_name
  @model_class_name
end

#report_nameObject (readonly)

the name of the report the result is based on



19
20
21
# File 'lib/saulabs/reportable/result_set.rb', line 19

def report_name
  @report_name
end

Instance Method Details

#to_aObject

array representation of the result



23
24
25
# File 'lib/saulabs/reportable/result_set.rb', line 23

def to_a
  @results
end