Class: Arca::Report
- Inherits:
-
Object
- Object
- Arca::Report
- Extended by:
- Forwardable
- Defined in:
- lib/arca/report.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Public: Arca::Model representing the ActiveRecord class being reported.
Instance Method Summary collapse
-
#calculated_permutations ⇒ Object
Public: Integer representing the possible number of permutations stemming from conditionals for an instance of the model being reported during the lifecycle of the object.
-
#callbacks_count ⇒ Object
Public: Integer representing the number of callbacks used in this model.
-
#conditionals_count ⇒ Object
Public: Integer representing the number of conditionals used in callback for the model being reported.
-
#initialize(model) ⇒ Report
constructor
Arca::Report takes an Arca::Model and compiles the analyzed callback data into a short overview report for the model.
-
#inspect ⇒ Object
Public: Hash representation of the object for interactive consoles.
-
#model_file_path ⇒ Object
Public: String file path of model.
-
#model_name ⇒ Object
Public: String class name of model.
-
#to_hash ⇒ Object
Public: Hash of compiled report data.
Constructor Details
#initialize(model) ⇒ Report
Arca::Report takes an Arca::Model and compiles the analyzed callback data into a short overview report for the model.
9 10 11 |
# File 'lib/arca/report.rb', line 9 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Public: Arca::Model representing the ActiveRecord class being reported.
14 15 16 |
# File 'lib/arca/report.rb', line 14 def model @model end |
Instance Method Details
#calculated_permutations ⇒ Object
Public: Integer representing the possible number of permutations stemming from conditionals for an instance of the model being reported during the lifecycle of the object.
63 64 65 66 67 |
# File 'lib/arca/report.rb', line 63 def calculated_permutations permutations = model.analyzed_callbacks.inject([]) do |results, (key, analyzed_callbacks)| results << 2 ** number_of_unique_conditionals(analyzed_callbacks) end.sum - number_of_unique_conditionals(model.analyzed_callbacks_array) end |
#callbacks_count ⇒ Object
Public: Integer representing the number of callbacks used in this model.
47 48 49 |
# File 'lib/arca/report.rb', line 47 def callbacks_count model.analyzed_callbacks_count end |
#conditionals_count ⇒ Object
Public: Integer representing the number of conditionals used in callback for the model being reported.
53 54 55 |
# File 'lib/arca/report.rb', line 53 def conditionals_count number_of_unique_conditionals(model.analyzed_callbacks_array) end |
#inspect ⇒ Object
Public: Hash representation of the object for interactive consoles.
17 18 19 |
# File 'lib/arca/report.rb', line 17 def inspect to_hash.to_s end |
#model_file_path ⇒ Object
Public: String file path of model.
42 43 44 |
# File 'lib/arca/report.rb', line 42 def model_file_path model.file_path end |
#model_name ⇒ Object
Public: String class name of model.
37 38 39 |
# File 'lib/arca/report.rb', line 37 def model_name model.name end |
#to_hash ⇒ Object
Public: Hash of compiled report data.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/arca/report.rb', line 22 def to_hash { :model_name => model_name, :model_file_path => Arca.relative_path(model_file_path), :callbacks_count => callbacks_count, :conditionals_count => conditionals_count, :lines_between_count => lines_between_count, :external_callbacks_count => external_callbacks_count, :external_targets_count => external_targets_count, :external_conditionals_count => external_conditionals_count, :calculated_permutations => calculated_permutations } end |