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