-
Notifications
You must be signed in to change notification settings - Fork 8
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 model class methods #35
Conversation
Move them to a separate module. Keep the AttrMasker module clean and minimal.
lib/attr_masker/model.rb
Outdated
}.merge!(attr_masker_options).merge!(attributes.last.is_a?(Hash) ? attributes.pop : {}) | ||
|
||
attributes.each do |attribute| | ||
masker_attributes[attribute.to_sym] = Attribute.new(attribute, self, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [85/80]
lib/attr_masker/model.rb
Outdated
:dump_method => "dump", | ||
:load_method => "load", | ||
:masker => AttrMasker::Maskers::SIMPLE, | ||
}.merge!(attr_masker_options).merge!(attributes.last.is_a?(Hash) ? attributes.pop : {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [93/80]
:marshaler => Marshal, | ||
:dump_method => "dump", | ||
:load_method => "load", | ||
:masker => AttrMasker::Maskers::SIMPLE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new Ruby 1.9 hash syntax.
:marshal => false, | ||
:marshaler => Marshal, | ||
:dump_method => "dump", | ||
:load_method => "load", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new Ruby 1.9 hash syntax.
:column_name => nil, | ||
:marshal => false, | ||
:marshaler => Marshal, | ||
:dump_method => "dump", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new Ruby 1.9 hash syntax.
lib/attr_masker/model.rb
Outdated
def attr_masker(*attributes) | ||
options = { | ||
:if => true, | ||
:unless => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new Ruby 1.9 hash syntax.
lib/attr_masker/model.rb
Outdated
# See README for more examples | ||
def attr_masker(*attributes) | ||
options = { | ||
:if => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the new Ruby 1.9 hash syntax.
lib/attr_masker/model.rb
Outdated
# @user.masker_configuration # returns the masker version of configuration | ||
# | ||
# See README for more examples | ||
def attr_masker(*attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method has too many lines. [13/10]
lib/attr_masker/model.rb
Outdated
# | ||
# class User | ||
# # now all attributes will be encoded and marshaled by default | ||
# attr_masker_options.merge!(:marshal => true, :some_other_option => true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [82/80]
lib/attr_masker/model.rb
Outdated
def self.extended(base) # :nodoc: | ||
base.class_eval do | ||
attr_writer :attr_masker_options | ||
@attr_masker_options, @masker_attributes = {}, {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use parallel assignment.
Reported Hound violations come from the original code. EDIT: Fixed anyway. |
Avoid lines which are too long.
86e60b9
to
3e163bf
Compare
# @user.masker_configuration # returns the masker version of configuration | ||
# | ||
# See README for more examples | ||
def attr_masker(*args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method has too many lines. [18/10]
Rewrite the method to make it more readable and fix most of code style violations.
3e163bf
to
d37d2de
Compare
Here hash rockets make things more readable.
d37d2de
to
87d5c35
Compare
@skalee this is very good. Could we also change to the 1.9 hash syntax and also document using RubyDocs? |
Move class methods to a separate
AttrMasker::Model
module, keep theAttrMasker
module as minimal and simple as possible.