Class: Verifly::DependentCallbacks::Callback
- Inherits:
-
ApplicatorWithOptions
- Object
- ApplicatorWithOptions
- Verifly::DependentCallbacks::Callback
- Defined in:
- lib/verifly/dependent_callbacks/callback.rb
Overview
ApplicatorWithOptions improved to handle everything needed in DependentCallbacks
Constant Summary collapse
- POSITIONS =
Available positions of calblack: before, after or around action
%i[before after around].freeze
Instance Attribute Summary collapse
-
#after ⇒ [Symbol]
names of calblacks after which this is.
-
#before ⇒ [Symbol]
names of calblacks before which this is.
-
#name ⇒ Symbol?
callback name.
-
#position ⇒ :before, ...
callback position.
Attributes inherited from ApplicatorWithOptions
#action, #if_condition, #unless_condition
Instance Method Summary collapse
-
#initialize(position, action = block, options = {}, &block) ⇒ Callback
constructor
A new instance of Callback.
-
#to_dot_label(binding_) ⇒ String
Converts callback to nice table in dot label format.
Methods inherited from ApplicatorWithOptions
Constructor Details
#initialize(position, action = block, options = {}, &block) ⇒ Callback
Returns a new instance of Callback.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 34 def initialize(position, *args, &block) super(*args, &block) action, = (*args, &block) self.name = .fetch(:name) { action if action.is_a?(Symbol) } self.position = position raise "#{position} should be one of #{POSITIONS}" unless POSITIONS.include?(position) self.before = Array(.fetch(:insert_before, [])) self.after = Array(.fetch(:require, [])) end |
Instance Attribute Details
#after ⇒ [Symbol]
names of calblacks after which this is
10 11 12 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 10 def after @after end |
#before ⇒ [Symbol]
names of calblacks before which this is
10 11 12 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 10 def before @before end |
#name ⇒ Symbol?
callback name
10 11 12 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 10 def name @name end |
#position ⇒ :before, ...
callback position
10 11 12 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 10 def position @position end |
Instance Method Details
#to_dot_label(binding_) ⇒ String
Converts callback to nice table in dot label format
51 52 53 54 55 56 |
# File 'lib/verifly/dependent_callbacks/callback.rb', line 51 def to_dot_label(binding_) template_path = File.("callback.dothtml.erb", __dir__) erb = ERB.new(File.read(template_path)) erb.filename = template_path erb.result(binding) end |