-
Notifications
You must be signed in to change notification settings - Fork 191
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
Allows the original options specified in enumerize to be retrieved from Enumerize::Attribute. #429
Allows the original options specified in enumerize to be retrieved from Enumerize::Attribute. #429
Conversation
…om Enumerize::Attribute.
lib/enumerize/attribute.rb
Outdated
@@ -13,6 +13,7 @@ def initialize(klass, name, options={}) | |||
@klass = klass | |||
@name = name.to_sym | |||
@i18n_scope = options[:i18n_scope] | |||
@origin_options = options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you name it simply options
or is there any meaning behind origin_options
name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nashby Thank you for your reply.
The options method already exists in Enumerize::Attribute
and I thought it appropriate to use an alias to maintain compatibility and avoid conflicts.
Since options is the name used for the enumerize method, I followed it.
For the above reasons, we named it origin_options
to indicate that it is an option specified by enumerize.
I wasn't sure whether to use original_options
or not, but I decided to use origin_options
because I wanted to make it shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name options is already in use, and we needed to avoid the name options to maintain compatibility. Therefore, we propose "arguments" as a simple name. Then we pushed.
test/attribute_test.rb
Outdated
describe 'origin options' do | ||
it 'returns original options' do | ||
build_attr nil, :foo, :in => [:a, :b], :scope => true | ||
expect(attr.origin_options).must_equal({:is => [:a, :b], :scope => true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
expect(attr.origin_options).must_equal({:is => [:a, :b], :scope => true}) | |
expect(attr.origin_options).must_equal({:in => [:a, :b], :scope => true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I fix it.
bb5134e
to
2229d82
Compare
This allows you to get the options specified by enumerize from an instance of Enumerize::Attribute.
I would like to use this to help create a DSL Compiler for Tapioca.