Class: ConfigTemplates::Contexts::Rendering

Inherits:
Object
  • Object
show all
Defined in:
lib/config_templates/contexts/rendering.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(extensions, settings, config) ⇒ Rendering

Returns a new instance of Rendering.



11
12
13
14
15
# File 'lib/config_templates/contexts/rendering.rb', line 11

def initialize(extensions, settings, config)
  @extensions = extensions
  @settings = settings
  @config = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



31
32
33
34
35
# File 'lib/config_templates/contexts/rendering.rb', line 31

def method_missing(method_name, *args, &block)
  extension = @extensions.find_by_name(method_name) || super
  invocation = ::ConfigTemplates::Extensions::Invocation.new method_name, args, block
  extension.call self, invocation
end

Instance Attribute Details

#componentObject

Returns the value of attribute component.



9
10
11
# File 'lib/config_templates/contexts/rendering.rb', line 9

def component
  @component
end

#componentsObject

Returns the value of attribute components.



9
10
11
# File 'lib/config_templates/contexts/rendering.rb', line 9

def components
  @components
end

Instance Method Details

#bindingObject



17
18
19
# File 'lib/config_templates/contexts/rendering.rb', line 17

def binding
  ::Kernel.binding
end

#param(xpath, default = nil) ⇒ Object



21
22
23
24
25
# File 'lib/config_templates/contexts/rendering.rb', line 21

def param(xpath, default = nil)
  xpath.split('.').reduce(@settings.find_all) { |value, key| value.fetch key }
rescue
  default
end

#respond_to_missing?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/config_templates/contexts/rendering.rb', line 37

def respond_to_missing?(method_name)
  @extensions.exists_with_name?(method_name) || super
end

#stageObject



27
28
29
# File 'lib/config_templates/contexts/rendering.rb', line 27

def stage
  @config.stage
end