-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
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
Override methods #144
Comments
Hey! Could you provide the runnable code snippet for the thing you want to get? |
yes, I would like do this:
Is possible do it directly in rewritten methods for description attribute? |
@vojta0001 looks like method gets overriden somewhere, but this seems to work class JsonModel::Lesson < JsonModel::Base
LOCALE = 'en'
attribute :duration, :float
attribute :description
def initialize(attributes = nil)
super(attributes)
end
def description_localized
description[LOCALE]
end
def description_localized=(val)
description[LOCALE] = val
end
end |
Hello,
I would like to override access methods in some store model class for example Post with attribute content of type string where I would like to add translation of data, similar as mobility gem. Raw data for the content attribute looks as {"en": "locale en", "cs": "locale cs"} and reader returns only locale which is already set. In writer update value for specific locale or update directly by method method_#{locale}.
I have already tried it, but without any success where I had problem to get the old value for this attribute in writer method. So is possible to get old and new values in writer to make some changes with both values?
The text was updated successfully, but these errors were encountered: