Class: Cult::ProjectContext

Inherits:
Object
  • Object
show all
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

CLI::ConsoleContext, Template::Context

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#projectObject (readonly)

Returns the value of attribute project.



13
14
15
# File 'lib/cult/project_context.rb', line 13

def project
  @project
end