Sha256: 27b429c9455a546f3d0fac8992e3077d194027f933015fb6bb04af09cb8888b0
Contents?: true
Size: 864 Bytes
Versions: 5
Compression:
Stored size: 864 Bytes
Contents
module Trestle class Scopes class Block attr_reader :block def initialize(&block) @block = 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) context.instance_exec(context, &block) context.scopes end class Evaluator include EvaluationContext attr_reader :scopes def initialize(context=nil) @context = context @scopes = [] end def scope(name, scope=nil, options={}, &block) if scope.is_a?(Hash) options = scope scope = nil end scopes << Scope.new(@context, name, options, &(scope || block)) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems