Module: Transproc
- Defined in:
- lib/transproc.rb,
lib/transproc/hash.rb,
lib/transproc/array.rb,
lib/transproc/class.rb,
lib/transproc/error.rb,
lib/transproc/object.rb,
lib/transproc/version.rb,
lib/transproc/composer.rb,
lib/transproc/function.rb,
lib/transproc/coercions.rb,
lib/transproc/composite.rb,
lib/transproc/recursion.rb,
lib/transproc/conditional.rb
Defined Under Namespace
Modules: ArrayTransformations, ClassTransformations, Coercions, Composer, Conditional, Functions, HashTransformations, Helper, ObjectTransformations, Recursion Classes: Composite, Function, MalformedInputError
Constant Summary collapse
- Error =
Class.new(StandardError)
- FunctionNotFoundError =
Class.new(Error)
- FunctionAlreadyRegisteredError =
Class.new(Error)
- VERSION =
'0.2.1'.freeze
Class Method Summary collapse
-
.[](name) ⇒ Object
private
Get registered function with provided name.
-
.functions ⇒ Object
private
Function registry.
-
.register(*args, &block) ⇒ Function
Register a new function.
Class Method Details
.[](name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get registered function with provided name
33 34 35 36 37 |
# File 'lib/transproc.rb', line 33 def [](name) functions.fetch(name) { raise FunctionNotFoundError, "no registered function for #{name}" } end |
.functions ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Function registry
42 43 44 |
# File 'lib/transproc.rb', line 42 def functions @_functions ||= {} end |
.register(*args, &block) ⇒ Function
Register a new function
20 21 22 23 24 25 26 |
# File 'lib/transproc.rb', line 20 def register(*args, &block) name, fn = *args if functions.include?(name) raise FunctionAlreadyRegisteredError, "function #{name} is already defined" end functions[name] = fn || block end |