Sha256: c98e0047a246f2522583fd006991c8dbe17a24fd3b493a6682fff9002d8bcaf6
Contents?: true
Size: 965 Bytes
Versions: 3
Compression:
Stored size: 965 Bytes
Contents
module Trestle class Scopes class Block attr_reader :block, :options def initialize(options={}, &block) @options, @block = options, block end # Evaluates the scope block within the given admin context # and returns an array of the scopes that were defined. def scopes(context) context = Evaluator.new(context, options) context.instance_exec(context, &block) context.scopes end class Evaluator include EvaluationContext attr_reader :scopes def initialize(context=nil, defaults={}) @context, @defaults = context, defaults @scopes = [] end def scope(name, scope=nil, options={}, &block) if scope.is_a?(Hash) options = scope scope = nil end scopes << Scope.new(@context, name, @defaults.merge(options), &(scope || block)) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.10.0 | lib/trestle/scopes/block.rb |
trestle-0.10.0.pre2 | lib/trestle/scopes/block.rb |
trestle-0.10.0.pre | lib/trestle/scopes/block.rb |