Class: Arcp::Job::Accepted
- Inherits:
-
Data
- Object
- Data
- Arcp::Job::Accepted
- Defined in:
- lib/arcp/job/accepted.rb
Instance Attribute Summary collapse
-
#accepted_at ⇒ Object
readonly
Returns the value of attribute accepted_at.
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#lease ⇒ Object
readonly
Returns the value of attribute lease.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(job_id:, agent:, accepted_at:, lease: nil, credentials: nil) ⇒ Accepted
constructor
A new instance of Accepted.
- #to_h ⇒ Object
Constructor Details
#initialize(job_id:, agent:, accepted_at:, lease: nil, credentials: nil) ⇒ Accepted
Returns a new instance of Accepted.
8 9 10 |
# File 'lib/arcp/job/accepted.rb', line 8 def initialize(job_id:, agent:, accepted_at:, lease: nil, credentials: nil) super end |
Instance Attribute Details
#accepted_at ⇒ Object (readonly)
Returns the value of attribute accepted_at
7 8 9 |
# File 'lib/arcp/job/accepted.rb', line 7 def accepted_at @accepted_at end |
#agent ⇒ Object (readonly)
Returns the value of attribute agent
7 8 9 |
# File 'lib/arcp/job/accepted.rb', line 7 def agent @agent end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials
7 8 9 |
# File 'lib/arcp/job/accepted.rb', line 7 def credentials @credentials end |
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id
7 8 9 |
# File 'lib/arcp/job/accepted.rb', line 7 def job_id @job_id end |
#lease ⇒ Object (readonly)
Returns the value of attribute lease
7 8 9 |
# File 'lib/arcp/job/accepted.rb', line 7 def lease @lease end |
Class Method Details
.credentials_from(h) ⇒ Object
30 31 32 33 34 |
# File 'lib/arcp/job/accepted.rb', line 30 def self.credentials_from(h) return nil unless h['credentials'] Array(h['credentials']).map { |credential| Arcp::Credential.from_h(credential) }.freeze end |
.from_h(h) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/arcp/job/accepted.rb', line 12 def self.from_h(h) h = h.transform_keys(&:to_s) new( job_id: h.fetch('job_id'), agent: h.fetch('agent'), accepted_at: h['accepted_at'], lease: h['lease'] ? Arcp::Lease::Lease.from_h(h['lease']) : nil, credentials: credentials_from(h) ) end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 |
# File 'lib/arcp/job/accepted.rb', line 23 def to_h out = { 'job_id' => job_id, 'agent' => agent, 'accepted_at' => accepted_at } out['lease'] = lease.to_h if lease out['credentials'] = credentials.map(&:to_h) if credentials && !credentials.empty? out end |