Module: Liquidscript::Generator::Base::Replacements
- Included in:
- Liquidscript::Generator::Base
- Defined in:
- lib/liquidscript/generator/base/replacements.rb
Instance Method Summary collapse
-
#replace(code, options = {}) ⇒ Object
Replace a code with a string.
-
#replacements ⇒ Hash
Access to the replacements method on the class.
Instance Method Details
#replace(code, options = {}) ⇒ Object
Replace a code with a string. This uses the replacement definitions that are a part of the class.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/liquidscript/generator/base/replacements.rb', line 11 def replace(code, = {}) method_name = :"generate_#{code.type}" if method(method_name).arity.abs == 1 send(method_name, code) else send(method_name, code, ) end rescue NoMethodError => e if e.name == method_name raise InvalidCodeError.new(code.type) else raise end end |
#replacements ⇒ Hash
Access to the replacements method on the class.
32 33 34 |
# File 'lib/liquidscript/generator/base/replacements.rb', line 32 def replacements self.class.replacements end |