Class: Eaco::DSL::Base
- Inherits:
-
Object
- Object
- Eaco::DSL::Base
- Defined in:
- lib/eaco/dsl/base.rb
Overview
Base DSL class. Provides handy access to the target class being manipulated, DSL-specific options, and a #target_eval helper to do instance_eval on the target.
Nothing too fancy.
Direct Known Subclasses
ACL, Actor, Actor::Designators, Resource, Resource::Permissions
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
DSL-specific options.
-
#target ⇒ Object
readonly
The target class of the manipulation.
Class Method Summary collapse
-
.eval(klass, options = {}, &block) ⇒ Base
Executes a DSL block in the context of a DSL manipulator.
Instance Method Summary collapse
-
#initialize(target, options) ⇒ Base
constructor
Sets up the DSL instance target class and the options.
-
#target_eval(&block)
protected
Evaluates the given block in the context of the target class.
Constructor Details
#initialize(target, options) ⇒ Base
Sets up the DSL instance target class and the options.
40 41 42 |
# File 'lib/eaco/dsl/base.rb', line 40 def initialize(target, ) @target, @options = target, end |
Instance Attribute Details
#options ⇒ Object (readonly)
DSL-specific options
32 33 34 |
# File 'lib/eaco/dsl/base.rb', line 32 def @options end |
#target ⇒ Object (readonly)
The target class of the manipulation
29 30 31 |
# File 'lib/eaco/dsl/base.rb', line 29 def target @target end |
Class Method Details
.eval(klass, options = {}, &block) ⇒ Base
Executes a DSL block in the context of a DSL manipulator.
22 23 24 25 26 |
# File 'lib/eaco/dsl/base.rb', line 22 def self.eval(klass, = {}, &block) new(klass, ).tap do |dsl| dsl.instance_eval(&block) if block end end |
Instance Method Details
#target_eval(&block) (protected)
This method returns an undefined value.
Evaluates the given block in the context of the target class
51 52 53 |
# File 'lib/eaco/dsl/base.rb', line 51 def target_eval(&block) target.instance_eval(&block) end |