Class: Isorun::Context
- Inherits:
-
Object
- Object
- Isorun::Context
- Defined in:
- lib/isorun/context.rb
Class Method Summary collapse
-
.create(options = default_options) {|context| ... } ⇒ Object
Creates a new context and yields the context as the first argument to the block.
Instance Method Summary collapse
-
#import(*export_names) ⇒ Object
Specify items you want to import from the module.
-
#receiver=(receiver) ⇒ Isorun::Context
The newly created context.
Class Method Details
.create(options = default_options) {|context| ... } ⇒ Object
Creates a new context and yields the context as the first argument to the block.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/isorun/context.rb', line 75 def create( = , &block) raise "[Isorun::Context] block missing when creating context" unless block context = Isorun::Context.new context.receiver = [:receiver] if [:receiver].present? result = yield(context) context.receiver = nil if [:receiver].present? result end |
Instance Method Details
#import(*export_names) ⇒ Object
Specify items you want to import from the module. If none is specified, the default export is taken.
118 119 120 121 122 |
# File 'lib/isorun/context.rb', line 118 def import(*export_names) export_names = [*export_names].map(&:to_s) export_names = [:default.to_s] if export_names.empty? Import.new(self, export_names) end |
#receiver=(receiver) ⇒ Isorun::Context
Returns the newly created context.
|
# File 'lib/isorun/context.rb', line 124
|