Sha256: e0cbc6b7b5e8fa0482c8a5713460f255e4deaef52a9642729235e72e68f7fd6e
Contents?: true
Size: 1.11 KB
Versions: 13
Compression:
Stored size: 1.11 KB
Contents
require 'listings/dynamic_binding' module Listings class ScopeDescriptor attr_accessor :human_name attr_accessor :name attr_accessor :params_lambda def initialize(*args) @props = args.extract_options! @props.reverse_merge! default: false @params_lambda = args.last if args.last.is_a? Proc if args.first.is_a? ::Symbol @name = args.first @human_name = @name.to_s.humanize else @name = args.second @human_name = args.first end end def is_default? @props[:default] end def apply(context, items) if name == :all items else if @params_lambda.nil? items.send(name) else ls = ::DynamicBinding::LookupStack.new ls.push_instance context ls.run_proc @params_lambda, items end end end def deferred? false end end class DeferredScopeDescriptor attr_accessor :block def initialize(&block) @block = block end def construct @block.call end def deferred? true end end end
Version data entries
13 entries across 13 versions & 1 rubygems