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

Extract rw_config into module, and clean it up a little. #434

Merged
merged 1 commit into from Oct 9, 2014

Conversation

tiegz
Copy link
Collaborator

@tiegz tiegz commented Oct 9, 2014

WHAT

Move rw_config into a module, and include that module in Authlogic::ActsAsAuthentic::Base and Authlogic::Session::Foundation. Tests included.

WHY

Currently rw_config is defined in the 2 modules, but their implementation is slightly different. We should make this easier to understand and test it.

private
# This is a one-liner method to write a config setting, read the config
# setting, and also set a default value for the setting.
def rw_config(key, value, default_value = nil)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

didn't include the read_value arg because it didn't seem to be used.

@tiegz
Copy link
Collaborator Author

tiegz commented Oct 9, 2014

cc @binarylogic/authlogic-maintainers

if value.nil?
acts_as_authentic_config.include?(key) ? acts_as_authentic_config[key] : default_value
else
self.acts_as_authentic_config = acts_as_authentic_config.merge(key => value)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the previous way of doing this (cloning the config) was a relic of Rails 3.1 compatibility, so that subclasses don't overwrite their parent class's config. We can achieve the same effect using merge.

tiegz added a commit that referenced this pull request Oct 9, 2014
Extract rw_config into module, and clean it up a little.
@tiegz tiegz merged commit 98f88d0 into master Oct 9, 2014
@tiegz tiegz deleted the cleanup_rw_config branch October 9, 2014 19:06
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

1 participant