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 model class methods #35

Merged
merged 7 commits into from
Aug 4, 2017
Merged

Extract model class methods #35

merged 7 commits into from
Aug 4, 2017

Conversation

skalee
Copy link
Contributor

@skalee skalee commented Aug 4, 2017

Move class methods to a separate AttrMasker::Model module, keep the AttrMasker module as minimal and simple as possible.

}.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)

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]

:dump_method => "dump",
:load_method => "load",
:masker => AttrMasker::Maskers::SIMPLE,
}.merge!(attr_masker_options).merge!(attributes.last.is_a?(Hash) ? attributes.pop : {})

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,

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",

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",

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.

def attr_masker(*attributes)
options = {
:if => true,
:unless => false,

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.

# See README for more examples
def attr_masker(*attributes)
options = {
:if => true,

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.

# @user.masker_configuration # returns the masker version of configuration
#
# See README for more examples
def attr_masker(*attributes)

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]

#
# class User
# # now all attributes will be encoded and marshaled by default
# attr_masker_options.merge!(:marshal => true, :some_other_option => true)

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]

def self.extended(base) # :nodoc:
base.class_eval do
attr_writer :attr_masker_options
@attr_masker_options, @masker_attributes = {}, {}

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.

@skalee
Copy link
Contributor Author

skalee commented Aug 4, 2017

Reported Hound violations come from the original code.

EDIT: Fixed anyway.

Avoid lines which are too long.
@skalee skalee force-pushed the move-class-methods branch 2 times, most recently from 86e60b9 to 3e163bf Compare August 4, 2017 19:32
# @user.masker_configuration # returns the masker version of configuration
#
# See README for more examples
def attr_masker(*args)

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.
Here hash rockets make things more readable.
@skalee skalee merged commit 1b2261b into master Aug 4, 2017
@skalee skalee deleted the move-class-methods branch August 4, 2017 19:54
@ronaldtse
Copy link
Contributor

@skalee this is very good. Could we also change to the 1.9 hash syntax and also document using RubyDocs?

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

3 participants