Class: C2::Reporter::Report
- Inherits:
-
Object
- Object
- C2::Reporter::Report
- Defined in:
- app/models/c2/reporter/report.rb
Instance Attribute Summary collapse
-
#buckets ⇒ Object
Returns the value of attribute buckets.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#options ⇒ Object
Returns the value of attribute options.
-
#refreshed_at ⇒ Object
Returns the value of attribute refreshed_at.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #id ⇒ Object
-
#initialize(klass_name, options = {}, &block) ⇒ Report
constructor
A new instance of Report.
- #klass ⇒ Object
- #label ⇒ Object
- #refresh ⇒ Object
Constructor Details
#initialize(klass_name, options = {}, &block) ⇒ Report
Returns a new instance of Report.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/c2/reporter/report.rb', line 11 def initialize(klass_name, ={}, &block) @options = .with_indifferent_access @buckets = [] @klass_name = klass_name @meta = @options.delete(:meta) instance_eval(&block) ::C2::Reporter.reports.push(self) end |
Instance Attribute Details
#buckets ⇒ Object
Returns the value of attribute buckets.
7 8 9 |
# File 'app/models/c2/reporter/report.rb', line 7 def buckets @buckets end |
#meta ⇒ Object
Returns the value of attribute meta.
9 10 11 |
# File 'app/models/c2/reporter/report.rb', line 9 def @meta end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'app/models/c2/reporter/report.rb', line 8 def @options end |
#refreshed_at ⇒ Object
Returns the value of attribute refreshed_at.
6 7 8 |
# File 'app/models/c2/reporter/report.rb', line 6 def refreshed_at @refreshed_at end |
Instance Method Details
#as_json(options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/models/c2/reporter/report.rb', line 40 def as_json(={}) { :id => self.id, :label => self.label, :buckets => self.buckets } end |
#id ⇒ Object
27 28 29 |
# File 'app/models/c2/reporter/report.rb', line 27 def id @klass_name.to_sym end |
#klass ⇒ Object
23 24 25 |
# File 'app/models/c2/reporter/report.rb', line 23 def klass @klass_cache ||= @klass_name.to_s.classify.constantize end |
#label ⇒ Object
31 32 33 |
# File 'app/models/c2/reporter/report.rb', line 31 def label @klass_name.to_s.pluralize.titleize end |
#refresh ⇒ Object
35 36 37 38 |
# File 'app/models/c2/reporter/report.rb', line 35 def refresh @buckets.each(&:refresh) @refreshed_at = Time.now.utc end |