We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to use StoreModel as a building block for composite types.
StoreModel
Let's imagine I'm trying to model Money. I'm not really doing that, but it's a nice domain
Money
Here's what I would do:
class MoneyModel include StoreModel::Model attribute :cents, :integer attribute :currency_code, :string end
The docs suggest that I use it like this:
attribute :amount, MoneyModel.to_type
However, I feel like it's not the way I'd like to use it, as I can register my custom types
So I add that line of code:
ActiveModel::Type.register(:money, MoneyModel.to_type)
Works well so far
However, when I try to run
attribute :amount, :money
I get a
Failure/Error: attribute :amount, :money NoMethodError: undefined method `new' for an instance of StoreModel::Types::One
Which is pretty fair considering how it all is implemented, because we can't register an instance of a type
However, the way to_type is implemented, we can't really achieve that using current representation, and it feels like we should have some way to do it
to_type
The text was updated successfully, but these errors were encountered:
Hey!
Sounds reasonable, I'd be happy to have such feature, but sounds like a huge job to be done to achieve that 🙂
Sorry, something went wrong.
No branches or pull requests
I'm trying to use
StoreModel
as a building block for composite types.Let's imagine I'm trying to model
Money
. I'm not really doing that, but it's a nice domainHere's what I would do:
The docs suggest that I use it like this:
However, I feel like it's not the way I'd like to use it, as I can register my custom types
So I add that line of code:
Works well so far
However, when I try to run
I get a
Which is pretty fair considering how it all is implemented, because we can't register an instance of a type
However, the way
to_type
is implemented, we can't really achieve that using current representation, and it feels like we should have some way to do itThe text was updated successfully, but these errors were encountered: