Class: MVCLI::Form::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/mvcli/form/input.rb

Defined Under Namespace

Classes: ListTarget, Target

Instance Method Summary collapse

Constructor Details

#initialize(name, target, options = {}, &block) ⇒ Input



5
6
7
8
# File 'lib/mvcli/form/input.rb', line 5

def initialize(name, target, options = {}, &block)
  @decoders = []
  @handler = handler(target).new name, target, options, &block
end

Instance Method Details

#decode(&block) ⇒ Object



10
11
12
13
# File 'lib/mvcli/form/input.rb', line 10

def decode(&block)
  @handler.decode &block
  return self
end

#handler(target) ⇒ Object



19
20
21
# File 'lib/mvcli/form/input.rb', line 19

def handler(target)
  target.is_a?(Array) ? ListTarget : Target
end

#value(source, context = nil) ⇒ Object



15
16
17
# File 'lib/mvcli/form/input.rb', line 15

def value(source, context = nil)
  @handler.value source, context
end