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

Temporarily fix OpenStruct with fix for class and method attributes #569

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

marcoroth
Copy link
Member

@marcoroth marcoroth commented Jan 18, 2022

Type of PR

Temporary fix

Description

OpenStruct 0.5.2 which comes bundled with Ruby 3.1 has a bug when creating an OpenStruct object with the class and method attributes in this order.

irb(main):003:0> os = OpenStruct.new(class: "my-class", method: "post")
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ostruct-0.5.2/lib/ostruct.rb:249:in `is_method_protected!': undefined method `ancestors' for "my-class":String (NoMethodError)

        self.class.ancestors.any? do |mod|
                  ^^^^^^^^^^
	from /Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ostruct-0.5.2/lib/ostruct.rb:223:in `new_ostruct_member!'

Why should this be added

Makes StimulusReflex work with Ruby 3.1, or any app that has openstruct 0.5.2 bundled with it.

We can remove this fix once ruby/ostruct#37 is merged, released and bundled with the next Ruby version.

Thanks @Laykou!

Checklist

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing
  • This is not a documentation update

@marcoroth marcoroth force-pushed the fix-for-openstruct-0.5.2 branch 2 times, most recently from aadb190 to c8fb62c Compare January 18, 2022 14:32
@Laykou
Copy link

Laykou commented Jan 19, 2022

btw ruby/ostruct#37 is already merged and new ostruct version released under 0.5.3

@marcoroth marcoroth merged commit 9287e4c into stimulusreflex:master Jan 20, 2022
@marcoroth marcoroth deleted the fix-for-openstruct-0.5.2 branch January 20, 2022 16:44
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.

3 participants