Module: Micro::Attributes::Utils::ExtractAttribute
- Defined in:
- lib/micro/attributes/utils.rb
Class Method Summary collapse
Class Method Details
.call(object, key:) ⇒ Object
41 42 43 44 45 |
# File 'lib/micro/attributes/utils.rb', line 41 def self.call(object, key:) return object.public_send(key) if object.respond_to?(key) Hashes.get(object, key) if object.respond_to?(:[]) end |
.from(object, keys:) ⇒ Object
47 48 49 50 51 |
# File 'lib/micro/attributes/utils.rb', line 47 def self.from(object, keys:) Kind::Of.(::Array, keys).each_with_object({}) do |key, memo| memo[key] = call(object, key: key) end end |