grosser / pru

Pipeable Ruby - forget about grep / sed / awk / wc ... use pure, readable Ruby!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArgumentError: You cannot pass a block and a method!

epirogov opened this issue · comments

ActiveRecord 3.0.3 and wrong sum on Array definition in pru

ArgumentError: You cannot pass a block and a method!
/opt/ruby192-p136/lib/ruby/gems/1.9.1/gems/pru-0.1.3/lib/pru.rb:39:in sum' /opt/ruby192-p136/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:21:ininstance_method_already_implemented?'
/opt/ruby192-p136/lib/ruby/gems/1.9.1/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:263:in `block (2 levels) in define_attribute_methods'

I don't think it is a good idea to highjack sum method on Array
may be better would be to sub-class Array and use it for array instantiation inside pru

what exactly fails, are you loading pru inside your project ??

I added it into Gemfile (so that I don't have to remember to install it separetly), didn't load it via explicit require,
wanted to have it on the server for command line processing utilities.

Now I excluded it from Gemfile and removed it from my toolbox.
I liked the idea though

with require => false it should be there, without overloading anything

could work, however it is a crutched solution, because one would have to remember about it for his next project.

I do not want to make some array subclass meta-magic, since this would break once you do something strange e.g. map{|x|x}.sum maybe someting like only adding sum if it is not already defined could work...

that can work