class Representable::Option

Extend ‘Trailblazer::Option` to support static values as callables too.

Public Class Methods

build(value) click to toggle source
Calls superclass method
# 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) click to toggle source
# File lib/representable/option.rb, line 6
def self.callable?(value)
  [Proc, Symbol, Uber::Callable].any?{ |kind| value.is_a?(kind) }
end