Class: OsCtld::CGroup::Param

Inherits:
Struct
  • Object
show all
Defined in:
lib/osctld/cgroup/param.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def name
  @name
end

#persistentObject

Returns the value of attribute persistent

Returns:

  • (Object)

    the current value of persistent



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def persistent
  @persistent
end

#subsystemObject

Returns the value of attribute subsystem

Returns:

  • (Object)

    the current value of subsystem



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def subsystem
  @subsystem
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



3
4
5
# File 'lib/osctld/cgroup/param.rb', line 3

def value
  @value
end

Class Method Details

.import(hash) ⇒ Object

Load from client



10
11
12
13
14
15
16
17
# File 'lib/osctld/cgroup/param.rb', line 10

def self.import(hash)
  new(
    hash[:subsystem],
    hash[:parameter],
    hash[:value],
    hash.has_key?(:persistent) ? hash[:persistent] : true
  )
end

.load(hash) ⇒ Object

Load from config



5
6
7
# File 'lib/osctld/cgroup/param.rb', line 5

def self.load(hash)
  new(hash['subsystem'], hash['name'], hash['value'], true)
end

Instance Method Details

#dumpObject

Dump to config



20
21
22
# File 'lib/osctld/cgroup/param.rb', line 20

def dump
  Hash[to_h.map { |k,v| [k.to_s, v] }]
end

#exportObject

Export to client



25
26
27
28
29
30
31
32
# File 'lib/osctld/cgroup/param.rb', line 25

def export
  {
    subsystem: subsystem,
    parameter: name,
    value: value,
    persistent: persistent ? true : false,
  }
end