Class: Kumogata2::Plugin::Ruby::Context
- Inherits:
-
Object
- Object
- Kumogata2::Plugin::Ruby::Context
- Defined in:
- lib/kumogata2/plugin/ruby/context.rb
Constant Summary collapse
- IGNORE_METHODS =
[:system]
Instance Method Summary collapse
-
#initialize(options) ⇒ Context
constructor
A new instance of Context.
- #post(&block) ⇒ Object
- #template(&block) ⇒ Object
Constructor Details
#initialize(options) ⇒ Context
Returns a new instance of Context.
4 5 6 |
# File 'lib/kumogata2/plugin/ruby/context.rb', line 4 def initialize() = end |
Instance Method Details
#post(&block) ⇒ Object
35 36 37 |
# File 'lib/kumogata2/plugin/ruby/context.rb', line 35 def post(&block) @_post = block end |
#template(&block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kumogata2/plugin/ruby/context.rb', line 8 def template(&block) key_converter = proc do |key| key = key.to_s key.gsub!('__', '::') unless .skip_replace_underscore? key end value_converter = proc do |v| case v when Hash, Array v else v.to_s end end @_template = Dslh.eval({ key_conv: key_converter, value_conv: value_converter, scope_hook: proc {|scope| define_template_func(scope, .path_or_url) }, filename: .path_or_url, ignore_methods: IGNORE_METHODS, }, &block) end |