Skip to content
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

Merged
merged 3 commits into from
Aug 12, 2023

Conversation

okoshi-f
Copy link
Contributor

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.

@@ -13,6 +13,7 @@ def initialize(klass, name, options={})
@klass = klass
@name = name.to_sym
@i18n_scope = options[:i18n_scope]
@origin_options = options
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

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})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Suggested change
expect(attr.origin_options).must_equal({:is => [:a, :b], :scope => true})
expect(attr.origin_options).must_equal({:in => [:a, :b], :scope => true})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I fix it.

@okoshi-f okoshi-f requested a review from nashby June 26, 2023 01:20
@okoshi-f okoshi-f force-pushed the add-methods-of-get-origin-options branch from bb5134e to 2229d82 Compare August 7, 2023 15:57
@nashby nashby merged commit 9dd65dd into brainspec:master Aug 12, 2023
41 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants