Module: Lambda::MicroVMs::Util
- Defined in:
- lib/lambda/microvms/util.rb
Overview
Internal helpers shared by resource objects.
Class Method Summary collapse
-
.extract(value, *keys) ⇒ Object?
Extract the first non-nil value from an object method or hash-like key.
-
.normalize_state(value) ⇒ Symbol
Normalize a provider state value into a lowercase symbol.
Class Method Details
.extract(value, *keys) ⇒ Object?
Extract the first non-nil value from an object method or hash-like key.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lambda/microvms/util.rb', line 14 def extract(value, *keys) keys.each do |key| if value.respond_to?(key) result = value.public_send(key) return result unless result.nil? end next unless value.respond_to?(:[]) begin result = value[key] return result unless result.nil? rescue KeyError, TypeError nil end end nil end |
.normalize_state(value) ⇒ Symbol
Normalize a provider state value into a lowercase symbol.
38 39 40 |
# File 'lib/lambda/microvms/util.rb', line 38 def normalize_state(value) value.to_s.downcase.to_sym end |