Class: Trestle::Scopes::Block
- Inherits:
-
Object
- Object
- Trestle::Scopes::Block
- Defined in:
- lib/trestle/scopes/block.rb
Defined Under Namespace
Classes: Evaluator
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Instance Method Summary collapse
-
#initialize(**defaults, &block) ⇒ Block
constructor
A new instance of Block.
-
#scopes(context) ⇒ Object
Evaluates the scope block within the given admin context and returns an array of the scopes that were defined.
Constructor Details
#initialize(**defaults, &block) ⇒ Block
Returns a new instance of Block.
6 7 8 |
# File 'lib/trestle/scopes/block.rb', line 6 def initialize(**defaults, &block) @defaults, @block = defaults, block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/trestle/scopes/block.rb', line 4 def block @block end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
4 5 6 |
# File 'lib/trestle/scopes/block.rb', line 4 def defaults @defaults end |
Instance Method Details
#scopes(context) ⇒ Object
Evaluates the scope block within the given admin context and returns an array of the scopes that were defined.
12 13 14 15 16 |
# File 'lib/trestle/scopes/block.rb', line 12 def scopes(context) context = Evaluator.new(context, **defaults) context.instance_exec(context, &block) context.scopes end |