lib/looksist/hashed.rb in looksist-0.0.2 vs lib/looksist/hashed.rb in looksist-0.0.3
- old
+ new
@@ -12,13 +12,14 @@
def inject(opts)
raise 'Incorrect usage' unless [:after, :using, :populate].all? { |e| opts.keys.include? e }
@rules ||= {}
@rules[opts[:after]] ||= []
@rules[opts[:after]] << opts
+
return if @rules[opts[:after]].length > 1
- define_method("#{opts[:after]}_with_inject") do
- hash = send("#{opts[:after]}_without_inject".to_sym)
+ define_method("#{opts[:after]}_with_inject") do |*args|
+ hash = send("#{opts[:after]}_without_inject".to_sym, *args)
self.class.instance_variable_get(:@rules)[opts[:after]].each do |opts|
keys = hash[opts[:at]][opts[:using]]
entity_name = entity(opts[:using])
values = Hashed.redis_service.send("#{entity_name}_for", keys)
hash[opts[:at]][opts[:populate]] = values