Module: Contextify::ClassMethods
- Defined in:
- lib/contextify/class_methods.rb
Instance Method Summary collapse
-
#contextify(name) ⇒ Object
Contextifies the class.
Instance Method Details
#contextify(name) ⇒ Object
Contextifies the class.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/contextify/class_methods.rb', line 11 def contextify(name) name = name.to_s @context_name = name extend ContextifiedClassMethods Contextify.contexts[name] = self # define the top-level context wrappers Kernel.module_eval %{ def #{name}(*args,&block) if (args.empty? && ::Contextify.is_pending?) ::Contextify.pending.blocks[#{name.dump}] = block return nil else new_context = #{self}.new(*args) new_context.instance_eval(&block) if block return new_context end end } end |