Module: Contextify::ContextifiedClassMethods
- Defined in:
- lib/contextify/contextified_class_methods.rb
Instance Attribute Summary collapse
-
#context_name ⇒ Object
readonly
The name of the context.
Instance Method Summary collapse
-
#load_context(path, *arguments) ⇒ Object
Loads a compatible context.
-
#load_context_block(path) ⇒ Proc
Loads a block defined under the context.
Instance Attribute Details
#context_name ⇒ Object (readonly)
The name of the context
4 5 6 |
# File 'lib/contextify/contextified_class_methods.rb', line 4 def context_name @context_name end |
Instance Method Details
#load_context(path, *arguments) ⇒ Object
Loads a compatible context.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/contextify/contextified_class_methods.rb', line 31 def load_context(path,*arguments) pending = Contextify.load_blocks(path) pending_name, pending_block = pending.find do |name,block| Contextify.contexts[name].ancestors.include?(self) end if (pending_name && pending_block) obj = Contextify.contexts[pending_name].new(*arguments) obj.instance_eval(&pending_block) obj end end |
#load_context_block(path) ⇒ Proc
Loads a block defined under the context.
15 16 17 |
# File 'lib/contextify/contextified_class_methods.rb', line 15 def load_context_block(path) Contextify.load_block(@context_name,path) end |