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

implemented a new feature that Hashie::Mash.load accepts a Pathname object #331 #336

Closed
wants to merge 3 commits into from

Conversation

gipcompany
Copy link
Contributor

As suggested on #331, I implemented the feature so that Hashie::Mash can also load a Pathname object.

@@ -11,6 +11,7 @@ def initialize(file_path)

def perform
template = ERB.new(@content)
@file_path = @file_path.to_s if @file_path.respond_to? :to_s
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right place to do this, if perform is called over and over again it's wasteful, and it's modifying the state of the object which feels like a side effect. Furthermore if I pass some junk that responds to to_s here we'll just try to load that, and that doesn't seem safe.

Ideally this should be directly supported by YAML.load, but short of that I would do this in initialize and more explicitly.

@file_path = file_path.is_a?(Pathname) ? file_path.to_s : file_path

@dblock
Copy link
Member

dblock commented Dec 26, 2015

Please also squash your commits and update CHANGELOG and README.

@gipcompany gipcompany closed this Dec 26, 2015
@gipcompany gipcompany deleted the 331_new_feature branch December 26, 2015 19:17
@gipcompany
Copy link
Contributor Author

@dblock , I updated the code as you suggested but accidentally I deleted this pull request. Sorry. So I newly created another pull request on #337 .

Could you see the page?

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.

None yet

2 participants