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() @options = end |
Instance Method Details
#post(&block) ⇒ Object
37 38 39 |
# File 'lib/kumogata2/plugin/ruby/context.rb', line 37 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 34 35 |
# File 'lib/kumogata2/plugin/ruby/context.rb', line 8 def template(&block) key_converter = proc do |k| k.to_s. gsub('_____', '-'). gsub('____', '.'). gsub('___', ':'). gsub('__', '::') 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, @options.path_or_url) }, filename: @options.path_or_url, ignore_methods: IGNORE_METHODS, }, &block) end |