Class: Deltacloud::BaseDriver::FeatureDecl

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud/base_driver/features.rb

Overview

The declaration of a feature, defines what operations are modified by it

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ FeatureDecl

Returns a new instance of FeatureDecl.



31
32
33
34
35
# File 'lib/deltacloud/base_driver/features.rb', line 31

def initialize(name, &block)
  @name = name
  @operations = []
  instance_eval &block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/deltacloud/base_driver/features.rb', line 29

def name
  @name
end

#operationsObject (readonly)

Returns the value of attribute operations.



29
30
31
# File 'lib/deltacloud/base_driver/features.rb', line 29

def operations
  @operations
end

Instance Method Details

#description(text = nil) ⇒ Object



37
38
39
40
# File 'lib/deltacloud/base_driver/features.rb', line 37

def description(text=nil)
  @description = text if text
  @description
end

#operation(name, &block) ⇒ Object

Add a new operation or modify an existing one through BLOCK



43
44
45
46
47
48
49
50
51
# File 'lib/deltacloud/base_driver/features.rb', line 43

def operation(name, &block)
  unless op = @operations.find { |op| op.name == name }
    op = Operation.new(name, &block)
    @operations << op
  else
    op.instance_eval(&block) if block_given?
  end
  op
end