Class: Middleman::CoreExtensions::Collections::StepContext

Inherits:
Object
  • Object
show all
Defined in:
middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ StepContext

Returns a new instance of StepContext



15
16
17
18
# File 'middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb', line 15

def initialize(app)
  @app = app
  @descriptors = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



20
21
22
23
24
25
26
27
28
29
30
# File 'middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb', line 20

def method_missing(name, *args, &block)
  internal = :_internal_#{name}"

  if respond_to?(internal)
    send(internal, *args, &block).tap do |r|
      @descriptors << r if r.respond_to?(:execute_descriptor)
    end
  else
    @app.config_context.send(name, *args, &block)
  end
end

Class Attribute Details

.currentObject

Returns the value of attribute current



6
7
8
# File 'middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb', line 6

def current
  @current
end

Instance Attribute Details

#descriptorsObject (readonly)

Returns the value of attribute descriptors



13
14
15
# File 'middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb', line 13

def descriptors
  @descriptors
end

Class Method Details

.add_to_context(name, &func) ⇒ Object



8
9
10
# File 'middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb', line 8

def add_to_context(name, &func)
  send(:define_method, :_internal_#{name}", &func)
end