Class: ReportsKit::Configuration
- Inherits:
-
Object
- Object
- ReportsKit::Configuration
- Defined in:
- lib/reports_kit/configuration.rb
Constant Summary collapse
- DEFAULT_PROPERTIES_METHOD =
lambda do |env| path = Rails.root.join('config', 'reports_kit', 'reports', "#{report_key}.yml") YAML.load_file(path) end
Instance Attribute Summary collapse
-
#autocomplete_results_method ⇒ Object
Returns the value of attribute autocomplete_results_method.
-
#cache_duration ⇒ Object
Returns the value of attribute cache_duration.
-
#cache_store ⇒ Object
Returns the value of attribute cache_store.
-
#context_record_method ⇒ Object
Returns the value of attribute context_record_method.
-
#custom_methods ⇒ Object
Returns the value of attribute custom_methods.
-
#default_dimension_limit ⇒ Object
Returns the value of attribute default_dimension_limit.
-
#default_properties ⇒ Object
Returns the value of attribute default_properties.
-
#first_day_of_week ⇒ Object
Returns the value of attribute first_day_of_week.
-
#modify_context_params_method ⇒ Object
Returns the value of attribute modify_context_params_method.
-
#properties_method ⇒ Object
Returns the value of attribute properties_method.
-
#report_filename_method ⇒ Object
Returns the value of attribute report_filename_method.
-
#use_concurrent_queries ⇒ Object
Returns the value of attribute use_concurrent_queries.
Instance Method Summary collapse
- #context_record(context) ⇒ Object
- #custom_method(method_name) ⇒ Object
- #evaluated_custom_methods ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/reports_kit/configuration.rb', line 12 def initialize self.autocomplete_results_method = nil self.cache_duration = 5.minutes self.cache_store = nil self.context_record_method = nil self.custom_methods = {} self.default_dimension_limit = 30 self.default_properties = nil self.first_day_of_week = :sunday self.modify_context_params_method = nil self.properties_method = DEFAULT_PROPERTIES_METHOD self.report_filename_method = nil self.use_concurrent_queries = false end |
Instance Attribute Details
#autocomplete_results_method ⇒ Object
Returns the value of attribute autocomplete_results_method.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def autocomplete_results_method @autocomplete_results_method end |
#cache_duration ⇒ Object
Returns the value of attribute cache_duration.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def cache_duration @cache_duration end |
#cache_store ⇒ Object
Returns the value of attribute cache_store.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def cache_store @cache_store end |
#context_record_method ⇒ Object
Returns the value of attribute context_record_method.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def context_record_method @context_record_method end |
#custom_methods ⇒ Object
Returns the value of attribute custom_methods.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def custom_methods @custom_methods end |
#default_dimension_limit ⇒ Object
Returns the value of attribute default_dimension_limit.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def default_dimension_limit @default_dimension_limit end |
#default_properties ⇒ Object
Returns the value of attribute default_properties.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def default_properties @default_properties end |
#first_day_of_week ⇒ Object
Returns the value of attribute first_day_of_week.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def first_day_of_week @first_day_of_week end |
#modify_context_params_method ⇒ Object
Returns the value of attribute modify_context_params_method.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def modify_context_params_method @modify_context_params_method end |
#properties_method ⇒ Object
Returns the value of attribute properties_method.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def properties_method @properties_method end |
#report_filename_method ⇒ Object
Returns the value of attribute report_filename_method.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def report_filename_method @report_filename_method end |
#use_concurrent_queries ⇒ Object
Returns the value of attribute use_concurrent_queries.
3 4 5 |
# File 'lib/reports_kit/configuration.rb', line 3 def use_concurrent_queries @use_concurrent_queries end |
Instance Method Details
#context_record(context) ⇒ Object
46 47 48 49 |
# File 'lib/reports_kit/configuration.rb', line 46 def context_record(context) return unless context_record_method context.instance_eval(&context_record_method) end |
#custom_method(method_name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/reports_kit/configuration.rb', line 27 def custom_method(method_name) return if method_name.blank? method = evaluated_custom_methods[method_name.to_sym] raise ArgumentError.new("A method named '#{method_name}' is not defined") unless method method end |
#evaluated_custom_methods ⇒ Object
34 35 36 37 38 |
# File 'lib/reports_kit/configuration.rb', line 34 def evaluated_custom_methods return custom_methods if custom_methods.is_a?(Hash) return custom_methods.call if custom_methods.is_a?(Proc) raise ArgumentError.new("Invalid type for custom_methods configuration: #{custom_methods.class}") end |