class Arca::Report
Attributes
Public: Arca::Model
representing the ActiveRecord class being reported.
Public Class Methods
Arca::Report
takes an Arca::Model
and compiles the analyzed callback data into a short overview report for the model.
# File lib/arca/report.rb, line 9 def initialize(model) @model = model end
Public Instance Methods
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.
# 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
Public: Integer representing the number of callbacks used in this model.
# File lib/arca/report.rb, line 47 def callbacks_count model.analyzed_callbacks_count end
Public: Integer representing the number of conditionals used in callback for the model being reported.
# File lib/arca/report.rb, line 53 def conditionals_count number_of_unique_conditionals(model.analyzed_callbacks_array) end
Public: Hash representation of the object for interactive consoles.
# File lib/arca/report.rb, line 17 def inspect to_hash.to_s end
Public: String file path of model.
# File lib/arca/report.rb, line 42 def model_file_path model.file_path end
Public: String class name of model.
# File lib/arca/report.rb, line 37 def model_name model.name end
Public: Hash of compiled report data.
# 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
Private Instance Methods
Internal: Integer representing the number of unique conditions for an Array of CallbackAnalysis
objects.
analyzed_callbacks - Array of CallbackAnalysis
objects.
Returns an Integer.
# File lib/arca/report.rb, line 75 def number_of_unique_conditionals(analyzed_callbacks) analyzed_callbacks. select {|analysis| analysis.conditional_symbol }. uniq {|analysis| analysis.conditional_target_symbol }. size end