My User model has some properties

  property :name, String
  property :email, String, :presence => true
  property :items, Array, :default => []
  (...)

Now when I want to use a Boolean:
  property :admin, Boolean

I get the following:

ruby-1.9.1-p378 > user = User.find('t...@gmail.com')
NameError: uninitialized constant User::Boolean
        from /Users/ftreacy/Documents/work/projects/ws/app/models/user.rb:30:in
`<class:User>'
        from /Users/ftreacy/Documents/work/projects/ws/app/models/user.rb:20:in
`<top (required)>'

Why isn't Ripple's Boolean not being found? What am I missing?

Francisco

ps: my current workaround: copy/paste the Module into user.rb - this works

module Boolean
  def self.ripple_cast(value)
    case value
    when NilClass
      nil
    when Numeric
      !value.zero?
    when TrueClass, FalseClass
      value
    when /^\s*t/i
      true
    when /^\s*f/i
      false
    else
      value.present?
    end
  end
end

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to