Class: Whisk::Resource::Bowl

Inherits:
Whisk::Resource show all
Defined in:
lib/whisk/resource/bowl.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, &block) ⇒ Bowl

Returns a new instance of Bowl.



29
30
31
32
33
34
# File 'lib/whisk/resource/bowl.rb', line 29

def initialize(name, &block)
  @provider = Whisk::Provider::Bowl
  @ingredients = {}

  super(name, &block)
end

Instance Attribute Details

#ingredientsObject (readonly)

Returns the value of attribute ingredients.



27
28
29
# File 'lib/whisk/resource/bowl.rb', line 27

def ingredients
  @ingredients
end

Instance Method Details

#environment(arg = nil) ⇒ Object



47
48
49
# File 'lib/whisk/resource/bowl.rb', line 47

def environment(arg=nil)
  set_or_return(:environment, arg, :kind_of => String)
end

#ingredient(iname, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/whisk/resource/bowl.rb', line 36

def ingredient(iname, &block)
  if ingredients.has_key? iname
    raise ArgumentError, "Ingredient '#{iname}' has already been added to bowl '#{name}'"
  else
    ingredients[iname] = Whisk::Resource::Ingredient.new(iname, self, &block)
    if refs_from_environment
      ingredients[iname].ref :ref_from_environment
    end
  end
end

#path(arg = nil) ⇒ Object



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

def path(arg=nil)
  if arg
    path = File.expand_path(arg)
  else
    path = nil
  end
  set_or_return(:path, path, :default => File.expand_path(File.join(Dir.getwd, name)))
end

#refs_from_environment(arg = nil) ⇒ Object



60
61
62
# File 'lib/whisk/resource/bowl.rb', line 60

def refs_from_environment(arg=nil)
  set_or_return(:refs_from_environment, arg, :kind_of => [TrueClass, FalseClass], :default => false)
end