Module: Contextify::ContextifiedClassMethods

Defined in:
lib/contextify/contextified_class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#context_nameObject (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.

Parameters:

  • path (String)

    The path to load the context from.

  • arguments (Array)

    Additional arguments to use when creating the context.

Returns:

  • (Object)

    The loaded 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.

Parameters:

  • path (String)

    The path to load the block from.

Returns:

  • (Proc)

    The block defined for 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