Module: Transproc::Transformer::Deprecated::ClassInterface
- Included in:
- Transproc::Transformer
- Defined in:
- lib/transproc/transformer/deprecated/class_interface.rb
Instance Method Summary collapse
-
#define { ... } ⇒ Function
(also: #build)
Define an anonymous transproc derived from given Transformer Evaluates block with transformations and returns initialized transproc.
- #inherited(subclass) ⇒ Object private
- #method_missing(method, *args, &block) ⇒ Object private
- #new(*args) ⇒ Object
- #respond_to_missing?(method, _include_private = false) ⇒ Boolean private
- #transproc ⇒ Object private
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ 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.
52 53 54 55 56 57 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 52 def method_missing(method, *args, &block) super unless container.contain?(method) func = block ? t(method, *args, define(&block)) : t(method, *args) transformations << func func end |
Instance Method Details
#define { ... } ⇒ Function Also known as: build
Define an anonymous transproc derived from given Transformer Evaluates block with transformations and returns initialized transproc. Does not mutate original Transformer
44 45 46 47 48 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 44 def define(&block) return transproc unless block_given? Class.new(Transformer[container]).tap { |klass| klass.instance_eval(&block) }.transproc 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.
16 17 18 19 20 21 22 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 16 def inherited(subclass) super if transformations.any? subclass.instance_variable_set('@transformations', transformations.dup) end end |
#new(*args) ⇒ Object
9 10 11 12 13 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 9 def new(*args) super(*args).tap do |transformer| transformer.instance_variable_set('@transproc', transproc) if transformations.any? end end |
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
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.
60 61 62 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 60 def respond_to_missing?(method, _include_private = false) super || container.contain?(method) end |
#transproc ⇒ 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.
65 66 67 |
# File 'lib/transproc/transformer/deprecated/class_interface.rb', line 65 def transproc transformations.reduce(:>>) end |