Class: Capistrano::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/callback.rb

Direct Known Subclasses

ProcCallback, TaskCallback

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Callback

Returns a new instance of Callback.



5
6
7
8
9
10
# File 'lib/capistrano/callback.rb', line 5

def initialize(source, options={})
  @source = source
  @options = options
  @only = Array(options[:only]).map { |v| v.to_s }
  @except = Array(options[:except]).map { |v| v.to_s }
end

Instance Attribute Details

#exceptObject (readonly)

Returns the value of attribute except.



3
4
5
# File 'lib/capistrano/callback.rb', line 3

def except
  @except
end

#onlyObject (readonly)

Returns the value of attribute only.



3
4
5
# File 'lib/capistrano/callback.rb', line 3

def only
  @only
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/capistrano/callback.rb', line 3

def options
  @options
end

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/capistrano/callback.rb', line 3

def source
  @source
end

Instance Method Details

#applies_to?(task) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/capistrano/callback.rb', line 12

def applies_to?(task)
  if task && only.any?
    return only.include?(task.fully_qualified_name)
  elsif task && except.any?
    return !except.include?(task.fully_qualified_name)
  else
    return true
  end
end