Class: Leeroy::State
- Inherits:
-
Types::Dash
- Object
- Hashie::Dash
- Types::Dash
- Leeroy::State
- Includes:
- Helpers::Dumpable, Helpers::Logging, Helpers::Polling, Helpers::State
- Defined in:
- lib/leeroy/state.rb
Constant Summary
Constants included from Helpers::Polling
Helpers::Polling::POLL_CALLBACK, Helpers::Polling::POLL_INTERVAL, Helpers::Polling::POLL_TIMEOUT
Constants included from Helpers::Logging
Helpers::Logging::TRACE_FORMAT, Helpers::Logging::TRACE_LEVELS, Helpers::Logging::TRUNCATE_THRESHOLD
Instance Attribute Summary
Attributes included from Helpers::State
Attributes included from Helpers::Polling
#poll_callback, #poll_interval, #poll_response, #poll_timeout
Attributes included from Helpers::Env
Attributes included from Helpers::Dumpable
Instance Method Summary collapse
- #fetch(*args, &block) ⇒ Object
-
#initialize(*args, &block) ⇒ State
constructor
A new instance of State.
- #method_missing(method, *args, &block) ⇒ Object
Methods included from Helpers::State
#dump_state, #load_state, #rotate_task_metadata, #state_from_pipe, #to_s
Methods included from Helpers::Polling
Methods included from Helpers::Env
Methods included from Helpers::Logging
Methods included from Helpers::Dumpable
Methods inherited from Types::Dash
Constructor Details
#initialize(*args, &block) ⇒ State
Returns a new instance of State.
60 61 62 63 64 65 66 67 |
# File 'lib/leeroy/state.rb', line 60 def initialize(*args, &block) super self.dump_properties = [ :data, :metadata, ] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/leeroy/state.rb', line 43 def method_missing(method, *args, &block) begin self.data.send(method.to_sym, *args, &block) rescue NoMethodError => e logger.debug e. if self.respond_to?(method.to_sym) self.send(method.to_sym, *args, &block) else raise e end rescue StandardError => e raise e end end |
Instance Method Details
#fetch(*args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/leeroy/state.rb', line 19 def fetch(*args, &block) begin self.data.send(:fetch, *args, &block) rescue KeyError => e logger.debug e. not_found = args[0] logger.debug "property '#{not_found}' not found in statedata, checking state" begin self.send(not_found.to_sym, &block) rescue KeyError => e logger.debug e. logger.warn "property '#{not_found}' not found in statedata or state" end rescue StandardError => e raise e end end |