makandra / active_type

Make any Ruby object quack like ActiveRecord
MIT License
1.09k stars 74 forks source link

Since 0.6.3 version it changes the way to Casting records or relations #77

Closed artero closed 7 years ago

artero commented 7 years ago

In the Readme say than the way to do "Casting records or relations" is using: ActiveType.cast

But in 0.6.3 version rise the next error:

undefined method `Util' for ActiveType:Module

I think the documentation sample should be change to:

class User < ActiveRecord::Base
  ...
end

class SignUp < ActiveType::Record[User]
  ...
end

user = User.find(1)
sign_up = ActiveType::Util.cast(user, SignUp)
sign_up.is_a?(SignUp) # => true
triskweline commented 7 years ago

The public API should remain ActiveType.cast(obj, type).

kratob commented 7 years ago

Fixed in 0.6.4, should work as ActiveType.cast again. Thanks for reporting!