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

Pass 'model_instance' as 'model:' into custom masker's Proc #58

Merged
merged 1 commit into from
Dec 29, 2017

Conversation

ribose-jeffreylau
Copy link
Contributor

This allows for something like this:

attr_masker :stuff, masker: ->(model:) { model.species =~ /cat/ ? 'miao' : 'woof' }

Ref #5

@ribose-jeffreylau ribose-jeffreylau self-assigned this Dec 29, 2017
expect { run_rake_task }.not_to(change { User.count })

expect { han.reload }.to(
change { han.first_name }.to("naHhan@example.test") &

Choose a reason for hiding this comment

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

Indent the first parameter one step more than the start of the previous line.

@@ -34,7 +34,7 @@ def should_mask?(model_instance)
# returning.
def mask(model_instance)
value = unmarshal_data(model_instance.send(name))
masker_value = options[:masker].call(options.merge!(value: value))
masker_value = options[:masker].call(options.merge!(value: value, model: model_instance))

Choose a reason for hiding this comment

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

Line is too long. [95/80]

@ronaldtse
Copy link
Contributor

LGTM!

@codecov
Copy link

codecov bot commented Dec 29, 2017

Codecov Report

Merging #58 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage    99.4%   99.39%   -0.01%     
==========================================
  Files          23       23              
  Lines         334      332       -2     
==========================================
- Hits          332      330       -2     
  Misses          2        2
Impacted Files Coverage Δ
lib/attr_masker/attribute.rb 100% <100%> (ø) ⬆️
lib/attr_masker/model.rb 94.73% <0%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57a5972...d873ba8. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Dec 29, 2017

Codecov Report

Merging #58 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage    99.4%   99.39%   -0.01%     
==========================================
  Files          23       23              
  Lines         334      333       -1     
==========================================
- Hits          332      331       -1     
  Misses          2        2
Impacted Files Coverage Δ
lib/attr_masker/attribute.rb 100% <100%> (ø) ⬆️
lib/attr_masker/model.rb 94.73% <0%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57a5972...b3d00cf. Read the comment docs.

@ronaldtse
Copy link
Contributor

Thanks @ribose-jeffreylau !

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

4 participants