Class: Conjur::LdapSyncJob
- Inherits:
-
Object
- Object
- Conjur::LdapSyncJob
- Defined in:
- lib/conjur/ldap_sync_job.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Class Method Summary collapse
-
.new_from_json(api, hash) ⇒ Object
Creates a new
LdapSyncJob
from a Hash as returned by the LDAP sync service'sGET /jobs
route.
Instance Method Summary collapse
- #[](k) ⇒ Object
-
#delete ⇒ Object
Stop this job (if running) and remove it from the list of jobs.
- #exclusive? ⇒ Boolean
-
#initialize(api, hash) ⇒ LdapSyncJob
constructor
A new instance of LdapSyncJob.
- #method_missing(sym, *arguments, &block) ⇒ Object
-
#output(&block) ⇒ Object
Receive output from this job and pass them to the given block.
- #to_h ⇒ Object (also: #as_json)
- #to_json(_unused) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(api, hash) ⇒ LdapSyncJob
Returns a new instance of LdapSyncJob.
14 15 16 17 |
# File 'lib/conjur/ldap_sync_job.rb', line 14 def initialize api, hash @api = api @hash = hash.with_indifferent_access end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *arguments, &block) ⇒ Object
27 28 29 |
# File 'lib/conjur/ldap_sync_job.rb', line 27 def method_missing(sym, *arguments, &block) @hash[sym] end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
6 7 8 |
# File 'lib/conjur/ldap_sync_job.rb', line 6 def hash @hash end |
Class Method Details
.new_from_json(api, hash) ⇒ Object
Creates a new LdapSyncJob
from a Hash as returned
by the LDAP sync service's GET /jobs
route.
10 11 12 |
# File 'lib/conjur/ldap_sync_job.rb', line 10 def self.new_from_json api, hash new(api, hash) end |
Instance Method Details
#[](k) ⇒ Object
23 24 25 |
# File 'lib/conjur/ldap_sync_job.rb', line 23 def [](k) @hash[k] end |
#delete ⇒ Object
Stop this job (if running) and remove it from the list of jobs.
32 33 34 |
# File 'lib/conjur/ldap_sync_job.rb', line 32 def delete job_resource.delete end |
#exclusive? ⇒ Boolean
19 20 21 |
# File 'lib/conjur/ldap_sync_job.rb', line 19 def exclusive? self.exclusive end |
#output(&block) ⇒ Object
Receive output from this job and pass them to the given block.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/conjur/ldap_sync_job.rb', line 37 def output &block events = [] wrapper = lambda do |e| events << e block[e] if block end follow_job_output(&wrapper) events end |
#to_h ⇒ Object Also known as: as_json
53 54 55 |
# File 'lib/conjur/ldap_sync_job.rb', line 53 def to_h @hash end |
#to_json(_unused) ⇒ Object
59 60 61 |
# File 'lib/conjur/ldap_sync_job.rb', line 59 def to_json _unused as_json.to_json end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/conjur/ldap_sync_job.rb', line 49 def to_s "<LdapSyncJob #{id} type=#{type} state=#{state}#{exclusive? ? ' exclusive' : ''}>" end |