Class: Vx::Builder::BuildConfiguration::Deploy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vx/builder/build_configuration/deploy/base.rb

Direct Known Subclasses

Shell

Constant Summary collapse

@@loaded =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



36
37
38
39
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 36

def initialize(params)
  @params = params.is_a?(Hash) ? params : {}
  self.branch = params["branch"]
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



34
35
36
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 34

def branch
  @branch
end

#paramsObject (readonly)

Returns the value of attribute params.



34
35
36
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 34

def params
  @params
end

Class Method Details

.detect(params) ⇒ Object



25
26
27
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 25

def detect(params)
  params.key?(key.to_s) if key
end

.keyObject



21
22
23
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 21

def key
  @key
end

.loadedObject



12
13
14
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 12

def loaded
  @@loaded
end

.module_by_key(val) ⇒ Object



29
30
31
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 29

def module_by_key(val)
  loaded.find{|i| i.key.to_s == val.to_s }
end

.provide(val) ⇒ Object



16
17
18
19
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 16

def provide(val)
  loaded.push self
  @key = val
end

Instance Method Details

#branch?(name) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 45

def branch?(name)
  case
  when branch.empty?
    true
  when !name
    true
  else
    branch.include?(name)
  end
end

#keyObject



56
57
58
59
60
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 56

def key
  if self.class.key
    @key ||= Array(params[self.class.key.to_s])
  end
end

#to_commandsObject



70
71
72
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 70

def to_commands
  nil
end

#to_hashObject



62
63
64
65
66
67
68
# File 'lib/vx/builder/build_configuration/deploy/base.rb', line 62

def to_hash
  if key
    { self.class.key.to_s => key }
  else
    {}
  end
end