module RedParse::Stackable::Meta
Attributes
boolean_identity_params[W]
identity_params[W]
Public Instance Methods
boolean_identity_params()
click to toggle source
# File lib/redparse/node.rb, line 138 def boolean_identity_params return @boolean_identity_params if defined?(@boolean_identity_params) and @boolean_identity_params @boolean_identity_params= if superclass.respond_to? :boolean_identity_params superclass.boolean_identity_params.dup else {} end end
build_exemplars()
click to toggle source
# File lib/redparse/node.rb, line 95 def build_exemplars exemplars=[[self]] (boolean_identity_params.merge identity_params).each{|name,variations| todo=[] variations=variations.dup variations.each{|var| exemplars.each{|exm| res=exm.dup #res.send name+"=", var #res.send :define_method, name do var end Symbol|String|Integer|true|false|nil===var or fail #so inspect works as a quoting #eval "def res.#{name}; #{var.inspect} end" res.push name, var todo<<res #unless exemplars.include? res } } exemplars=todo } #by now, may be some exemplars with identical identities... #those duplicate identities should be culled # identities_seen={} # exemplars.delete_if{|ex| # idn=ex.identity_name # chuck_it=identities_seen[idn] # identities_seen[idn]=true # chuck_it # } return exemplars end
enumerate_exemplars()
click to toggle source
# File lib/redparse/node.rb, line 92 def enumerate_exemplars @exemplars||= build_exemplars end
identity_param(name, *variations)
click to toggle source
declare name to be part of the identity of current class variations are the allowed values for name in this class keep variations simple: booleans, integers, symbols and strings only
# File lib/redparse/node.rb, line 66 def identity_param name, *variations name=name.to_s list= if (variations-[true,false,nil]).empty? #const_get("BOOLEAN_IDENTITY_PARAMS") rescue const_set("BOOLEAN_IDENTITY_PARAMS",{}) self.boolean_identity_params else #const_get("IDENTITY_PARAMS") rescue const_set("IDENTITY_PARAMS",{}) self.identity_params end list[name]=variations return #old way to generate examplars below =begin old_exemplars=self.exemplars||=[allocate] exemplars=[] variations.each{|var| old_exemplars.each{|exm| exemplars<< res=exm.dup #res.send name+"=", var #res.send :define_method, name do var end Symbol|String|Integer|true|false|nil===var or fail #so inspect works as a quoting eval "def res.#{name}; #{var.inspect} end" }} old_exemplars.replace exemplars =end end
identity_params()
click to toggle source
# File lib/redparse/node.rb, line 129 def identity_params return @identity_params if defined?(@identity_params) and @identity_params @identity_params= if superclass.respond_to? :identity_params superclass.identity_params.dup else {} end end