Class: Crew::Context::DSL
- Inherits:
-
Object
- Object
- Crew::Context::DSL
- Defined in:
- lib/crew/context/dsl.rb
Instance Method Summary collapse
- #adapter(name_or_module, opts = {}) ⇒ Object
- #hint(hint) ⇒ Object
-
#initialize(context, &blk) ⇒ DSL
constructor
A new instance of DSL.
- #load(file = nil, &blk) ⇒ Object
Constructor Details
#initialize(context, &blk) ⇒ DSL
Returns a new instance of DSL.
4 5 6 |
# File 'lib/crew/context/dsl.rb', line 4 def initialize(context, &blk) @context = context end |
Instance Method Details
#adapter(name_or_module, opts = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/crew/context/dsl.rb', line 18 def adapter(name_or_module, opts = {}) @context.adapter_name = name_or_module.to_s @context.extend name_or_module.is_a?(Module) ? name_or_module : Context.const_get(name_or_module.to_s) @context.opts = opts end |
#hint(hint) ⇒ Object
24 25 26 |
# File 'lib/crew/context/dsl.rb', line 24 def hint(hint) @context.hints << hint end |
#load(file = nil, &blk) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/crew/context/dsl.rb', line 8 def load(file = nil, &blk) if file instance_eval File.read(file), file, 1 @context.source = file elsif blk instance_eval(&blk) @context.source = blk.source_location.join(":") end end |