Module: Amrita2::Util::OptionSupport

Included in:
Core::DefaultFilter, Filters::Each, Filters::ToHash, Option
Defined in:
lib/amrita2/template.rb

Overview

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



281
282
283
284
285
286
287
# File 'lib/amrita2/template.rb', line 281

def method_missing(sym, *args, &block)
  if @opt and @opt.has_key?(sym)
    @opt[sym]
  else
    super
  end
end

Instance Attribute Details

#optObject (readonly)

Returns the value of attribute opt.



262
263
264
# File 'lib/amrita2/template.rb', line 262

def opt
  @opt
end

Instance Method Details

#[](key) ⇒ Object



277
278
279
# File 'lib/amrita2/template.rb', line 277

def [](key)
  @opt[key]
end

#parse_opt(*args) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/amrita2/template.rb', line 263

def parse_opt(*args)
  @opt = {}
  hash = args.last
  if hash.kind_of?(Hash)
    @opt.merge!(hash)
    args.pop
  end

  args.each do |key|
    @opt[key] = key
  end
  @opt
end