class HashMath::Mapper::Lookup
A Lookup
instance maintains its own list of objects using its own key extraction method, called 'by' which will be used to extract the key's value for the lookup. If 'by' is a Proc then it will be called when extracting a new lookup record's lookup value. If it is anything other than a Proc and it will call [] on the object.
Attributes
by[R]
name[R]
objects[R]
Public Class Methods
new(name:, by:)
click to toggle source
# File lib/hash_math/mapper/lookup.rb, line 21 def initialize(name:, by:) @name = name @by = by @objects = {} freeze end
Private Instance Methods
proc_or_brackets(object, thing)
click to toggle source
# File lib/hash_math/mapper/lookup.rb, line 49 def proc_or_brackets(object, thing) return nil unless object thing.is_a?(Proc) ? thing.call(object) : object[thing] end