Class: Smooth::Presentable::AttributeDelegator
- Inherits:
-
Object
- Object
- Smooth::Presentable::AttributeDelegator
- Defined in:
- lib/smooth/presentable.rb
Class Method Summary collapse
Class Method Details
.pluck(record, attribute, memo) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/smooth/presentable.rb', line 27 def self.pluck(record, attribute, memo) if attribute.is_a?(Symbol) || attribute.is_a?(String) memo[attribute] = record.send(attribute) return memo end if attribute.is_a?(Hash) key = attribute[:attribute] || attribute[:key] meth = attribute[:method] || key presenter = attribute[:presenter] || :default value = record.send(meth) memo[key] = value.send(:present_as, presenter) end return memo end |