Module: Acclaim::Option::Type
- Extended by:
- Enumerable
- Defined in:
- lib/acclaim/option/type.rb,
lib/acclaim/option/type/uri.rb,
lib/acclaim/option/type/date.rb,
lib/acclaim/option/type/time.rb,
lib/acclaim/option/type/float.rb,
lib/acclaim/option/type/string.rb,
lib/acclaim/option/type/symbol.rb,
lib/acclaim/option/type/complex.rb,
lib/acclaim/option/type/integer.rb,
lib/acclaim/option/type/pathname.rb,
lib/acclaim/option/type/rational.rb,
lib/acclaim/option/type/date_time.rb,
lib/acclaim/option/type/big_decimal.rb
Overview
Associates a class with a handler block.
Defined Under Namespace
Modules: BigDecimal, Complex, Date, DateTime, Float, Integer, Pathname, Rational, String, Symbol, Time, URI
Class Method Summary collapse
-
.all ⇒ Object
(also: registered)
Returns all registered classes.
-
.each(&block) ⇒ Object
Yields class, proc pairs if a block was given.
-
.handler_for(klass) ⇒ Object
(also: [])
Returns the handler for the given class.
-
.register(*klasses, &block) ⇒ Object
(also: add_handler_for, accept)
Registers a handler for a class.
Class Method Details
.all ⇒ Object Also known as: registered
Returns all registered classes.
21 22 23 |
# File 'lib/acclaim/option/type.rb', line 21 def all table.keys end |
.each(&block) ⇒ Object
Yields class, proc pairs if a block was given. Returns an enumerator otherwise.
13 14 15 |
# File 'lib/acclaim/option/type.rb', line 13 def each(&block) table.each &block end |
.handler_for(klass) ⇒ Object Also known as: []
Returns the handler for the given class.
31 32 33 34 35 |
# File 'lib/acclaim/option/type.rb', line 31 def handler_for(klass) table.fetch klass do raise "#{klass} does not have an associated handler" end end |
.register(*klasses, &block) ⇒ Object Also known as: add_handler_for, accept
Registers a handler for a class.
26 27 28 |
# File 'lib/acclaim/option/type.rb', line 26 def register(*klasses, &block) klasses.each { |klass| table[klass] = block } end |