Class: Gandi::Operation

Inherits:
Object
  • Object
show all
Includes:
GandiObjectMethods
Defined in:
lib/gandi/operation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GandiObjectMethods

#[], included, #inspect, #to_hash

Constructor Details

#initialize(operation_id, information_attributes = nil) ⇒ Operation

Returns a new instance of Operation.



9
10
11
12
# File 'lib/gandi/operation.rb', line 9

def initialize(operation_id, information_attributes = nil)
  @id = operation_id
  @attributes = information_attributes || info
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/gandi/operation.rb', line 7

def id
  @id
end

Class Method Details

.count(opts = {}) ⇒ Object

Count operations visible by this account.



36
37
38
# File 'lib/gandi/operation.rb', line 36

def count(opts = {})
  call('operation.count', opts)
end

.list(opts = {}, map_operations = true) ⇒ Object

List operations done by this account. The array of returned operations are mapped to Operation objects unless map_operations is set to false.



42
43
44
45
46
47
48
49
50
# File 'lib/gandi/operation.rb', line 42

def list(opts = {}, map_operations = true)
  operations = call('operation.list', opts)
  if map_operations
    operations.map! do |operation|
      self.new(operation['id'], operation)
    end
  end
  operations
end

Instance Method Details

#cancelObject

Set the step of an operation to CANCEL.



28
29
30
31
32
# File 'lib/gandi/operation.rb', line 28

def cancel
  result = self.class.call('operation.cancel', @id)
  @attributes['step'] = 'CANCEL' if result
  return result
end

#infoObject

Return some attributes of a operation visible by this account.



15
16
17
# File 'lib/gandi/operation.rb', line 15

def info
  self.class.call('operation.info', @id)
end