Class: Representable::Option
- Inherits:
-
Trailblazer::Option
- Object
- Trailblazer::Option
- Representable::Option
- Defined in:
- lib/representable/option.rb
Overview
Extend ‘Trailblazer::Option` to support static values as callables too.
Class Method Summary collapse
Class Method Details
.build(value) ⇒ Object
10 11 12 13 |
# File 'lib/representable/option.rb', line 10 def self.build(value) return ->(*) { value } unless callable?(value) # Wrap static `value` into a proc. super end |
.callable?(value) ⇒ Boolean
6 7 8 |
# File 'lib/representable/option.rb', line 6 def self.callable?(value) [Proc, Symbol, Uber::Callable].any?{ |kind| value.is_a?(kind) } end |