Class: Cult::ProjectContext
- Inherits:
-
Object
- Object
- Cult::ProjectContext
- Extended by:
- Forwardable
- Defined in:
- lib/cult/project_context.rb
Overview
Project Context is a binding useful for “cult console” and templates. It makes it so “nodes” and “roles” return something useful.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
-
#initialize(project, **extra) ⇒ ProjectContext
constructor
A new instance of ProjectContext.
- #method_missing(*args) ⇒ Object
Constructor Details
#initialize(project, **extra) ⇒ ProjectContext
Returns a new instance of ProjectContext.
15 16 17 18 19 20 21 |
# File 'lib/cult/project_context.rb', line 15 def initialize(project, **extra) @project = project extra.each do |k, v| v.respond_to?(:call) ? define_singleton_method(k, &v) : define_singleton_method(k) { v } end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
23 24 25 |
# File 'lib/cult/project_context.rb', line 23 def method_missing(*args) project.send(*args) end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
13 14 15 |
# File 'lib/cult/project_context.rb', line 13 def project @project end |