Class: OsCtld::LocalTransfer::Log::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/local_transfer/log.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Options

Returns a new instance of Options.

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/osctld/local_transfer/log.rb', line 41

def initialize(opts)
  opts = opts.dup

  @operation = opts.delete(:operation).to_sym
  @target_pool = opts.delete(:target_pool)
  @target_id = opts.delete(:target_id)
  @target_dataset = opts.delete(:target_dataset)
  @target_dataset_custom = opts.delete(:target_dataset_custom) || false
  @target_user = opts.delete(:target_user)
  @target_group = opts.delete(:target_group)
  @network_interfaces = opts.delete(:network_interfaces)
  @datasets = (opts.delete(:datasets) || []).map do |v|
    v.is_a?(Dataset) ? v : Dataset.load(v)
  end

  return if opts.empty?

  raise ArgumentError, "unsupported options: #{opts.keys.join(', ')}"
end

Instance Attribute Details

#datasetsObject (readonly)

Returns the value of attribute datasets.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def datasets
  @datasets
end

#network_interfacesObject (readonly)

Returns the value of attribute network_interfaces.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def network_interfaces
  @network_interfaces
end

#operationObject (readonly)

Returns the value of attribute operation.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def operation
  @operation
end

#target_datasetObject (readonly)

Returns the value of attribute target_dataset.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_dataset
  @target_dataset
end

#target_dataset_customObject (readonly)

Returns the value of attribute target_dataset_custom.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_dataset_custom
  @target_dataset_custom
end

#target_groupObject (readonly)

Returns the value of attribute target_group.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_group
  @target_group
end

#target_idObject (readonly)

Returns the value of attribute target_id.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_id
  @target_id
end

#target_poolObject (readonly)

Returns the value of attribute target_pool.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_pool
  @target_pool
end

#target_userObject (readonly)

Returns the value of attribute target_user.



33
34
35
# File 'lib/osctld/local_transfer/log.rb', line 33

def target_user
  @target_user
end

Class Method Details

.load(cfg) ⇒ Object



37
38
39
# File 'lib/osctld/local_transfer/log.rb', line 37

def self.load(cfg)
  new(cfg.transform_keys(&:to_sym))
end

Instance Method Details

#copy?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/osctld/local_transfer/log.rb', line 61

def copy?
  operation == :copy
end

#dumpObject



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/osctld/local_transfer/log.rb', line 69

def dump
  {
    'operation' => operation.to_s,
    'target_pool' => target_pool,
    'target_id' => target_id,
    'target_dataset' => target_dataset,
    'target_dataset_custom' => target_dataset_custom,
    'target_user' => target_user,
    'target_group' => target_group,
    'network_interfaces' => network_interfaces,
    'datasets' => datasets.map(&:dump)
  }
end

#move?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/osctld/local_transfer/log.rb', line 65

def move?
  operation == :move
end