Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Oct 4, 2017
1 parent 1c7d615 commit 416f6bc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
67 changes: 35 additions & 32 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
inherit_gem:
rubocop-rails:
- config/rails.yml

AllCops:
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'

# frozen_string_literal: true
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: when_needed

# Prefer &&/|| over and/or.
Style/AndOr:
Expand All @@ -17,78 +20,78 @@ Style/BracesAroundHashParameters:
Enabled: true

# Align `when` with `case`.
Style/CaseIndentation:
Layout/CaseIndentation:
Enabled: true

# Align comments with method definitions.
Style/CommentIndentation:
Layout/CommentIndentation:
Enabled: true

# No extra empty lines.
Style/EmptyLines:
Layout/EmptyLines:
Enabled: true

# In a regular class definition, no empty lines around the body.
Style/EmptyLinesAroundClassBody:
Layout/EmptyLinesAroundClassBody:
Enabled: true

# In a regular method definition, no empty lines around the body.
Style/EmptyLinesAroundMethodBody:
Layout/EmptyLinesAroundMethodBody:
Enabled: true

# In a regular module definition, no empty lines around the body.
Style/EmptyLinesAroundModuleBody:
Layout/EmptyLinesAroundModuleBody:
Enabled: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
# Use Ruby >= 1.9 syntax for hashes. Prefer {a: :b} over { :a => :b }.
Style/HashSyntax:
Enabled: true

# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Style/IndentationConsistency:
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails
EnforcedStyle: normal

# Two spaces, no tabs (for indentation).
Style/IndentationWidth:
Layout/IndentationWidth:
Enabled: true

Style/SpaceAfterColon:
Layout/SpaceAfterColon:
Enabled: true

Style/SpaceAfterComma:
Layout/SpaceAfterComma:
Enabled: true

Style/SpaceAroundEqualsInParameterDefault:
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true

Style/SpaceAroundKeyword:
Layout/SpaceAroundKeyword:
Enabled: true

Style/SpaceAroundOperators:
Layout/SpaceAroundOperators:
Enabled: true

Style/SpaceBeforeFirstArg:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true

# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true

# Use `foo {}` not `foo{}`.
Style/SpaceBeforeBlockBraces:
Layout/SpaceBeforeBlockBraces:
Enabled: true

# Use `foo { bar }` not `foo {bar}`.
Style/SpaceInsideBlockBraces:
Layout/SpaceInsideBlockBraces:
Enabled: true

# Use `{ a: 1 }` not `{a:1}`.
Style/SpaceInsideHashLiteralBraces:
Enabled: true
# Use `{a: 1}` not `{ a:1 }`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: false

Style/SpaceInsideParens:
Layout/SpaceInsideParens:
Enabled: true

# Check quotes usage according to lint rule below.
Expand All @@ -97,15 +100,15 @@ Style/StringLiterals:
EnforcedStyle: double_quotes

# Detect hard tabs, no hard tabs.
Style/Tab:
Layout/Tab:
Enabled: true

# Blank lines should not have any spaces.
Style/TrailingBlankLines:
Layout/TrailingBlankLines:
Enabled: true

# No trailing whitespace.
Style/TrailingWhitespace:
Layout/TrailingWhitespace:
Enabled: true

# Use quotes for string literals when they are enough.
Expand Down
2 changes: 1 addition & 1 deletion lib/options_model/concerns/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def attribute(name, cast_type, default: nil, array: false)
def #{name}
value = attributes[:#{name}]
return value unless value.nil?
attributes[:#{name}] = self.class.attribute_defaults[:#{name}]#{default_extractor}}
attributes[:#{name}] = self.class.attribute_defaults[:#{name}]#{default_extractor}
attributes[:#{name}]
end
STR
Expand Down
4 changes: 3 additions & 1 deletion lib/options_model/concerns/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def to_h
hash = {}

hash.merge! unused_attributes if self.class.with_unused_attributes?
hash.merge! attributes
self.class.attribute_names_for_inlining.each do |name|
hash[name] = send(:"#{name}")
end
hash.merge! nested_attributes.reduce({}) { |h, (k, v)| h[k] = v.to_h; h }

hash
Expand Down

0 comments on commit 416f6bc

Please sign in to comment.