Class: Whisk::Resource::Ingredient

Inherits:
Whisk::Resource show all
Includes:
Chef::Mixin::ParamsValidate
Defined in:
lib/whisk/resource/ingredient.rb

Instance Attribute Summary collapse

Attributes inherited from Whisk::Resource

#name, #provider

Instance Method Summary collapse

Methods inherited from Whisk::Resource

#run_action

Constructor Details

#initialize(name, bowl, &block) ⇒ Ingredient

Returns a new instance of Ingredient.



30
31
32
33
34
35
36
37
38
# File 'lib/whisk/resource/ingredient.rb', line 30

def initialize(name, bowl, &block)
  @bowl = bowl
  @provider = Whisk::Provider::Ingredient
  @ref = nil
  @remotes = {}
  @source = nil

  super(name, &block)
end

Instance Attribute Details

#bowlObject

Returns the value of attribute bowl.



28
29
30
# File 'lib/whisk/resource/ingredient.rb', line 28

def bowl
  @bowl
end

#remotesObject

Returns the value of attribute remotes.



28
29
30
# File 'lib/whisk/resource/ingredient.rb', line 28

def remotes
  @remotes
end

Instance Method Details

#pathObject



40
41
42
# File 'lib/whisk/resource/ingredient.rb', line 40

def path
  File.join(self.bowl.path, self.name)
end

#ref(arg = nil) ⇒ Object



48
49
50
# File 'lib/whisk/resource/ingredient.rb', line 48

def ref(arg=nil)
  set_or_return(:ref, arg, :kind_of => [String, Symbol])
end

#remote(rname, url) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/whisk/resource/ingredient.rb', line 52

def remote(rname, url)
  if remotes.has_key?(name)
    raise ArgumentError, "remote #{rname} already defined for ingredient #{name}"
  else
    remotes[rname] = url
  end
end

#source(arg = nil) ⇒ Object



44
45
46
# File 'lib/whisk/resource/ingredient.rb', line 44

def source(arg=nil)
  set_or_return(:source, arg, :required => true)
end