module ItegrationAttr
Public Instance Methods
compact_link_itgt(*names)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 180 def compact_link_itgt(*names) link_itgt(*names) # container_hash = get_itgt_var('itegration_compact_link_hash',{}) # ## 为每个link生成一个保存attr的list # names.each do |name| # unless container_hash[name.to_s] # container_hash[name.to_s] = [] # end # end # set_itgt_var('itegration_compact_link_hash',container_hash) ## 存入 list container = get_itgt_var('itegration_compact_link_collect',[]) container = container | names.map { |e| e.to_s } set_itgt_var('itegration_compact_link_collect',container) # # ## 生成2级类方法 # names.each do |name| # # define_singleton_method("#{name}_has_attr") do |*argvs| # # puts argvs # # return 90 # # ItegrationVerb[name] # ## 把 attr 保存到 list # container_hash = get_itgt_var('itegration_compact_link_hash',{}) # container_hash[name.to_s] = container_hash[name.to_s] | argvs.map { |e| e.to_s } # set_itgt_var('itegration_compact_link_hash',container_hash) # end # # define_singleton_method("#{name}_has_flag") do |*argvs| # "itgt 标识" # container_hash = get_itgt_var('itegration_compact_flag_hash',{}) # container_hash[name.to_s] ||= [] # container_hash[name.to_s] = container_hash[name.to_s] | argvs.map { |e| e.to_s } # set_itgt_var('itegration_compact_flag_hash',container_hash) # end # # end end
get_itgt_var(name,default=[])
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 3 def get_itgt_var(name,default=[]) unless instance_variable_get("@_#{name}_") instance_variable_set("@_#{name}_",default) container = instance_variable_get("@_#{name}_") else container = instance_variable_get("@_#{name}_") end return container end
has_attr(*names)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 123 def has_attr(*names) link_explort(*names) end
has_flag(*names)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 127 def has_flag(*names) ## 标识控制 container = get_itgt_var('itegration_flag_collect',[]) container = container | names.map{ |e| e.to_s } set_itgt_var("itegration_flag_collect",container) end
itegration_explort()
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 28 def itegration_explort instance_variable_get("@_itegration_explort_collect_") end
itegration_hash()
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 20 def itegration_hash instance_variable_get("@_itegration_link_hash_") end
itegration_link()
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 24 def itegration_link instance_variable_get("@_itegration_link_collect_") end
link_explort(*names)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 32 def link_explort(*names) ## explort_active_hash explort_active_hash = get_itgt_var('explort_active_hash',{}) ## explort_silence_hash explort_silence_hash = get_itgt_var('explort_silence_hash',{}) ## 存入 list # unless instance_variable_get("@_itegration_explort_collect_") # instance_variable_set("@_itegration_explort_collect_",[]) # container = instance_variable_get("@_itegration_explort_collect_") # else # container = instance_variable_get("@_itegration_explort_collect_") # end container = get_itgt_var('itegration_explort_collect',[]) container = container | names.map{ |e| e.to_s } instance_variable_set("@_itegration_explort_collect_",container) ## 定义引用输出是发生的情况 names.each do |name| define_singleton_method("active_#{name}") do |names_pool_signal=nil,&block| unless names_pool_signal explort_active_hash[name.to_s] = block else explort_active_hash[name.to_s] = names_pool_signal.to_s end end define_singleton_method("silence_#{name}") do |&block| explort_silence_hash[name.to_s] = block end end ## 生成实例方法 self.class_exec do names.each do |name| define_method("active_#{name}_proc_run") do itgt_inst = self inst_explort_active_hash = get_itgt_var('explort_active_hash'){ explort_active_hash.clone } inst_explort_run_hash = get_itgt_var('explort_active_run_record',{}) inst_explort_silence_hash = get_itgt_var('explort_silence_hash'){ explort_silence_hash.clone } inst_explort_silence_hash.delete(name.to_s) ## 如果运行过则,从记录中加载 if inst_explort_run_hash[name.to_s] return inst_explort_run_hash[name.to_s] end ## 没有要激活的proc 则直接调用 unless inst_explort_active_hash[name.to_s] return itgt_inst.send(name.to_s) end itgt_inst.set_itgt_var('explort_silence_hash',inst_explort_silence_hash) if inst_explort_active_hash[name.to_s].is_a? String brel = inst_explort_active_hash[name.to_s].snoop(itgt_inst,itgt_inst.top_module) elsif inst_explort_active_hash[name.to_s] # $_implicit_curr_itgt_ = itgt_inst ItegrationVerb.curr_itgt_push itgt_inst brel = itgt_inst.top_module.instance_exec(itgt_inst,&inst_explort_active_hash[name.to_s]) ItegrationVerb.curr_itgt_pop end ## 运行一次后删掉 inst_explort_active_hash.delete(name.to_s) # 记录 inst_explort_run_hash[name.to_s] = brel itgt_inst.set_itgt_var('explort_active_run_record',inst_explort_run_hash) itgt_inst.set_itgt_var('explort_active_hash',inst_explort_active_hash) brel end end define_method('silence_procs_run') do inst_explort_silence_hash = get_itgt_var('explort_silence_hash',explort_silence_hash.clone) # $_implicit_curr_itgt_ = self ItegrationVerb.curr_itgt_push self inst_explort_silence_hash.each_value do |v| self.top_module.instance_exec(self,&v) if v end ItegrationVerb.curr_itgt_pop end end end
link_itgt(*names)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 134 def link_itgt(*names) container_hash = get_itgt_var('itegration_link_hash',{}) ## 为每个link生成一个保存attr的list names.each do |name| unless container_hash[name.to_s] container_hash[name.to_s] = [] end end set_itgt_var('itegration_link_hash',container_hash) ## 存入 list container = get_itgt_var('itegration_link_collect',[]) container = container | names.map { |e| e.to_s } set_itgt_var('itegration_link_collect',container) ## 生成实例方法 # self.class_exec do # names.each do |name| # define_method(name) do # ItegrationVerb[name] # end # end # end ## 生成2级类方法 names.each do |name| define_singleton_method("#{name}_has_attr") do |*argvs| # puts argvs # return 90 # ItegrationVerb[name] ## 把 attr 保存到 list container_hash = get_itgt_var('itegration_link_hash',{}) container_hash[name.to_s] = container_hash[name.to_s] | argvs.map { |e| e.to_s } set_itgt_var('itegration_link_hash',container_hash) end define_singleton_method("#{name}_has_flag") do |*argvs| "itgt 标识" container_hash = get_itgt_var('itegration_flag_hash',{}) container_hash[name.to_s] ||= [] container_hash[name.to_s] = container_hash[name.to_s] | argvs.map { |e| e.to_s } set_itgt_var('itegration_flag_hash',container_hash) end end end
param(name,default)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 219 def param(name,default) ## param_hash # itgt_param_hash = get_itgt_var('itgt_param_hash',{}) # itgt_param_hash[name.to_s] = default # set_itgt_var('itgt_param_hash',itgt_param_hash) ## 生成实例方法 self.class_exec do define_method(name) do # ItegrationVerb[name] itgt_param_hash = get_itgt_var('itgt_param_hash',{}) if itgt_param_hash[name.to_s] return itgt_param_hash[name.to_s] else itgt_param_hash[name.to_s] = default set_itgt_var('itgt_param_hash',itgt_param_hash) return default end end define_method("#{name}=") do |value| # ItegrationVerb[name] itgt_param_hash = get_itgt_var('itgt_param_hash',{}) itgt_param_hash[name.to_s] = value set_itgt_var('itgt_param_hash',itgt_param_hash) value end end end
set_itgt_var(name,value)
click to toggle source
# File lib/tdl/exlib/itegration_verb.rb, line 14 def set_itgt_var(name,value) # rel = get_itgt_var(name) instance_variable_set("@_#{name}_",value) container = instance_variable_get("@_#{name}_") end