Module: Transproc::Transformer::ClassInterface
- Included in:
- Transproc::Transformer
- Defined in:
- lib/transproc/transformer/class_interface.rb
Instance Attribute Summary collapse
- #dsl ⇒ Object readonly private
Instance Method Summary collapse
-
#[](container) ⇒ subclass of Transproc::Transformer
Return a base Transproc::Transformer class with the container configured to the passed argument.
-
#container(container = Undefined) ⇒ Transproc::Registry
private
Get or set the container to resolve transprocs from.
- #define!(&block) ⇒ Object
- #import(*args) ⇒ Object
- #inherited(subclass) ⇒ Object private
- #new ⇒ Object
-
#t(fn, *args) ⇒ Transproc::Function
Get a transformation from the container, without adding it to the transformation pipeline.
Instance Attribute Details
#dsl ⇒ Object (readonly)
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.
10 11 12 |
# File 'lib/transproc/transformer/class_interface.rb', line 10 def dsl @dsl end |
Instance Method Details
#[](container) ⇒ subclass of Transproc::Transformer
Return a base Transproc::Transformer class with the container configured to the passed argument.
26 27 28 29 30 |
# File 'lib/transproc/transformer/class_interface.rb', line 26 def [](container) klass = Class.new(self) klass.container(container) klass end |
#container(container = Undefined) ⇒ Transproc::Registry
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 or set the container to resolve transprocs from.
59 60 61 62 63 64 65 |
# File 'lib/transproc/transformer/class_interface.rb', line 59 def container(container = Undefined) if container.equal?(Undefined) @container ||= Module.new.extend(Transproc::Registry) else @container = container end end |
#define!(&block) ⇒ Object
73 74 75 76 77 |
# File 'lib/transproc/transformer/class_interface.rb', line 73 def define!(&block) @dsl ||= DSL.new(container) @dsl.instance_eval(&block) self end |
#import(*args) ⇒ Object
68 69 70 |
# File 'lib/transproc/transformer/class_interface.rb', line 68 def import(*args) container.import(*args) end |
#inherited(subclass) ⇒ 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.
33 34 35 36 37 38 39 |
# File 'lib/transproc/transformer/class_interface.rb', line 33 def inherited(subclass) super subclass.container(@container) if defined?(@container) subclass.instance_variable_set('@dsl', dsl.dup) if dsl end |
#new ⇒ Object
80 81 82 83 84 |
# File 'lib/transproc/transformer/class_interface.rb', line 80 def new(*) super.tap do |transformer| transformer.instance_variable_set('@transproc', dsl.(transformer)) if dsl end end |
#t(fn, *args) ⇒ Transproc::Function
Get a transformation from the container, without adding it to the transformation pipeline
108 109 110 |
# File 'lib/transproc/transformer/class_interface.rb', line 108 def t(fn, *args) container[fn, *args] end |