I would like to create a custom Typecaster for the ActiveAttr Gem.
I have a Package
class:
class Package
include ActiveAttr::Model
attribute :quantity, :type => Integer
attribute :detail
attribute :type
attribute :order
def shipping
end
end
and I have Order
class
class Order
include ActiveAttr::Model
attribute :id, :type => Integer
def test
end
end
In the Package class I want to use attribute :order, :type => OrderTypecaster
because when I create a new package (p = Package.new(params['package']
) I would like to set the Order id attribute automatically.
Is this possible?
I'm using Rails 3.2.13
Tks!