Skip to content

Instantly share code, notes, and snippets.

@thommay
Created September 29, 2010 16:34
Show Gist options
  • Select an option

  • Save thommay/603074 to your computer and use it in GitHub Desktop.

Select an option

Save thommay/603074 to your computer and use it in GitHub Desktop.
irb >> m = Multicast.create({:addr => "1.2.3.4", :port => 1})
/usr/lib/ruby/gems/1.8/gems/simply_stored-0.3.8/lib/simply_stored.rb:7: warning: already initialized constant VERSION
NoMethodError: undefined method `to_i' for true:TrueClass
from /usr/lib/ruby/1.8/ipaddr.rb:449:in `initialize'
from /usr/lib/ruby/1.8/ipaddr.rb:499:in `new'
from /usr/lib/ruby/1.8/ipaddr.rb:499:in `coerce_other'
from /usr/lib/ruby/1.8/ipaddr.rb:140:in `=='
from /usr/lib/ruby/gems/1.8/gems/validatable-1.6.7/lib/validations/validates_true_for.rb:6:in `valid?'
from /usr/lib/ruby/gems/1.8/gems/validatable-1.6.7/lib/validatable_instance_methods.rb:74:in `run_validation'
so i hacked IPAddr#initialize to print the addr and the addr's class I was passing to IPAddr.new and got:
1.2.3.4
String
true
TrueClass
wtf?
class Multicast
include SimplyStored::Couch
property :addr
property :port
validates_true_for :addr, :logic => lambda { IPAddr.new addr }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment