Class: Plutonium::Query::AdhocBlock
- Defined in:
- lib/plutonium/query/adhoc_block.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #apply(scope, context: nil) ⇒ Object
-
#initialize(body) ⇒ AdhocBlock
constructor
Initializes a AdhocBlock with a given block of code.
Methods included from Definition::Presentable
Constructor Details
#initialize(body) ⇒ AdhocBlock
Initializes a AdhocBlock with a given block of code.
9 10 11 12 |
# File 'lib/plutonium/query/adhoc_block.rb', line 9 def initialize(body) super() @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/plutonium/query/adhoc_block.rb', line 4 def body @body end |
Instance Method Details
#apply(scope, context: nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/plutonium/query/adhoc_block.rb', line 14 def apply(scope, context: nil, **) if context context.instance_exec(scope, **, &body) else body.call(scope, **) end end |