Class: Contextify::PendingContext

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/contextify/pending_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PendingContext

Creates a new PendingContext object.

Parameters:

  • path (String)

    The path the pending context was loaded from.



18
19
20
21
# File 'lib/contextify/pending_context.rb', line 18

def initialize(path)
  @path = File.expand_path(path)
  @blocks = {}
end

Instance Attribute Details

#blocksObject

The blocks to be loaded



10
11
12
# File 'lib/contextify/pending_context.rb', line 10

def blocks
  @blocks
end

#pathObject (readonly)

The path being loaded



7
8
9
# File 'lib/contextify/pending_context.rb', line 7

def path
  @path
end

Instance Method Details

#each {|name, block| ... } ⇒ Object

Iterates over each context name and block in the pending context.

Yields:

  • (name, block)

    The block will be passed each pending context block and it's context name.

Yield Parameters:

  • name (String)

    The context name of the block.

  • block (Proc)

    A pending context block.



64
65
66
# File 'lib/contextify/pending_context.rb', line 64

def each(&block)
  @blocks.each(&block)
end

#each_block {|block| ... } ⇒ Object

Iterates over each block in the pending context.

Yields:

  • (block)

    The block will be passed each pending context block.

Yield Parameters:

  • block (Proc)

    A pending context block.



47
48
49
# File 'lib/contextify/pending_context.rb', line 47

def each_block(&block)
  @blocks.each_value(&block)
end

#each_class {|name| ... } ⇒ Object

Iterates over each context name in the pending context.

Yields:

  • (name)

    The block will be passed each name of the pending context blocks.

Yield Parameters:

  • name (String)

    The name of a pending context block.



32
33
34
35
36
# File 'lib/contextify/pending_context.rb', line 32

def each_class(&block)
  @blocks.each_key do |name|
    block.call(Contextify.contexts[name])
  end
end