class EacRubyUtils::Compact
def attribute_value(attr_path)
-
(Object)
-
Parameters:
-
attr_path
(String, Symbol
) -- A path separated by +ATTRIBUTE_SEPARATOR+.
def attribute_value(attr_path) attr_path.to_s.split(ATTRIBUTE_SEPARATOR).inject(object) do |a, e| a.send(e) end end
def initialize(object, attributes)
def initialize(object, attributes) @object = object @attributes = attributes end
def to_a
-
(Array)
-
def to_a attributes.map { |attr| attribute_value(attr) } end
def to_h
-
(Hash)
-
def to_h attributes.to_h { |attr| [attr.to_sym, attribute_value(attr)] } end