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

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStepContext

Returns a new instance of StepContext.



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

def initialize
  @descriptors = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
19
20
21
22
23
# File 'lib/middleman-core/core_extensions/collections/step_context.rb', line 15

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

  return super unless respond_to?(internal)

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

Instance Attribute Details

#descriptorsObject (readonly)

Returns the value of attribute descriptors.



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

def descriptors
  @descriptors
end

Class Method Details

.add_to_context(name, &func) ⇒ Object



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

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