Class: Minicontext::Router::Maybe

Inherits:
Object
  • Object
show all
Defined in:
lib/minicontext/router.rb

Direct Known Subclasses

Just, Noting

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ Maybe

Returns a new instance of Maybe.



4
5
6
# File 'lib/minicontext/router.rb', line 4

def initialize(val)
  @val = val
end

Instance Method Details

#[](name) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/minicontext/router.rb', line 12

def [](name)
  klass = case val = @val.(name)
          when Context then Maybe
          when Proc    then Just
          else              Noting
          end

  klass.new(val)
end

#valueObject



8
9
10
# File 'lib/minicontext/router.rb', line 8

def value
  @val
end