Class: RubyExt::Callbacks::AbstractCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ext/more/callbacks.rb

Direct Known Subclasses

AfterCallback, AroundCallback, BeforeCallback

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



8
9
10
# File 'lib/ruby_ext/more/callbacks.rb', line 8

def conditions
  @conditions
end

#executorObject

Returns the value of attribute executor.



3
4
5
# File 'lib/ruby_ext/more/callbacks.rb', line 3

def executor
  @executor
end

Instance Method Details

#run?(target, method, data) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ruby_ext/more/callbacks.rb', line 24

def run? target, method, data
  if cond = conditions[:if]
    evaluate_if(cond, target, data)
  elsif cond = conditions[:unless]
    !evaluate_if(cond, target, data)
  elsif cond = conditions[:only]
    evaluate_only(cond, method, data)
  elsif cond = conditions[:except]
    !evaluate_only(cond, method, data)
  else
    true
  end
end