Class: Capistrano::Baptize::PolicyDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/baptize/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role, parent) ⇒ PolicyDefinition

Returns a new instance of PolicyDefinition.



11
12
13
14
15
# File 'lib/baptize/dsl.rb', line 11

def initialize(role, parent)
  @role = role
  @dependencies = []
  @parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/baptize/dsl.rb', line 21

def method_missing(sym, *args, &block)
  if @parent.respond_to?(sym)
    @parent.send(sym, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



9
10
11
# File 'lib/baptize/dsl.rb', line 9

def dependencies
  @dependencies
end

#roleObject (readonly)

Returns the value of attribute role.



9
10
11
# File 'lib/baptize/dsl.rb', line 9

def role
  @role
end

Instance Method Details

#full_nameObject



29
30
31
# File 'lib/baptize/dsl.rb', line 29

def full_name
  "baptize:policies:#{role}"
end

#requires(*tasks) ⇒ Object



33
34
35
36
37
# File 'lib/baptize/dsl.rb', line 33

def requires(*tasks)
  Array(tasks).flatten.each do |name|
    @dependencies << (name.kind_of?(Symbol) ? "baptize:packages:#{name}" : name.to_s)
  end
end

#respond_to?(sym, include_priv = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/baptize/dsl.rb', line 17

def respond_to?(sym, include_priv = false)
  super || @parent.respond_to?(sym, include_priv)
end