Class: PuppetX::Relay::Agent::Model::Run

Inherits:
Object
  • Object
show all
Includes:
Stateful
Defined in:
lib/puppet_x/relay/agent/model/run.rb

Defined Under Namespace

Classes: MissingScopeError

Instance Attribute Summary collapse

Attributes included from Stateful

#id, #state

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stateful

#with_state

Constructor Details

#initialize(opts) ⇒ Run

Returns a new instance of Run.

Parameters:

  • opts (Hash)

Raises:



36
37
38
39
40
41
42
# File 'lib/puppet_x/relay/agent/model/run.rb', line 36

def initialize(opts)
  opts = defaults.merge(opts)

  raise MissingScopeError unless opts.key? 'scope'

  opts.each { |key, value| instance_variable_set("@#{key}", value) }
end

Instance Attribute Details

#debugBoolean (readonly)

Returns:

  • (Boolean)


33
34
35
# File 'lib/puppet_x/relay/agent/model/run.rb', line 33

def debug
  @debug
end

#environmentString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/puppet_x/relay/agent/model/run.rb', line 27

def environment
  @environment
end

#evaltraceBoolean (readonly)

Returns:

  • (Boolean)


33
34
35
# File 'lib/puppet_x/relay/agent/model/run.rb', line 33

def evaltrace
  @evaltrace
end

#noopBoolean (readonly)

Returns:

  • (Boolean)


33
34
35
# File 'lib/puppet_x/relay/agent/model/run.rb', line 33

def noop
  @noop
end

#scopeScope (readonly)

Returns:



30
31
32
# File 'lib/puppet_x/relay/agent/model/run.rb', line 30

def scope
  @scope
end

#traceBoolean (readonly)

Returns:

  • (Boolean)


33
34
35
# File 'lib/puppet_x/relay/agent/model/run.rb', line 33

def trace
  @trace
end

Class Method Details

.from_h(hsh) ⇒ Object



18
19
20
21
22
23
# File 'lib/puppet_x/relay/agent/model/run.rb', line 18

def from_h(hsh)
  hsh = hsh.dup
  hsh['scope'] = Scope.from_h(hsh['scope']) if hsh.key? 'scope'
  hsh['state'] = State.from_h(hsh['state']) if hsh.key? 'state'
  new(hsh)
end

Instance Method Details

#to_json(*args) ⇒ String

Returns:

  • (String)


45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/puppet_x/relay/agent/model/run.rb', line 45

def to_json(*args)
  {
    id: id,
    environment: environment,
    scope: scope,
    noop: noop,
    debug: debug,
    trace: trace,
    evaltrace: evaltrace,
    state: state,
  }.to_json(*args)
end