diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:05:58 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:17:49 -0200 |
commit | fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2 (patch) | |
tree | 49257bdeadca12d5b167800a25d58dd50c0d6ddb /activemodel/lib/active_model | |
parent | f81a5ffbdec6c1d748aaef02ba10a6e0d86cbf3f (diff) | |
download | rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.gz rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.bz2 rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.zip |
Add more rubocop rules about whitespaces
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/model.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/serializers/json.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/helpers/time_value.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/acceptance.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validations/length.rb | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/validator.rb | 2 |
9 files changed, 10 insertions, 10 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 17ed5de420..14adfa081f 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -211,7 +211,7 @@ module ActiveModel # # <error>name can't be blank</error> # # <error>name must be specified</error> # # </errors> - def to_xml(options={}) + def to_xml(options = {}) to_a.to_xml({ root: "errors", skip_types: true }.merge!(options)) end @@ -221,7 +221,7 @@ module ActiveModel # # person.errors.as_json # => {:name=>["cannot be nil"]} # person.errors.as_json(full_messages: true) # => {:name=>["name cannot be nil"]} - def as_json(options=nil) + def as_json(options = nil) to_hash(options && options[:full_messages]) end diff --git a/activemodel/lib/active_model/model.rb b/activemodel/lib/active_model/model.rb index f5765c0c54..e683050787 100644 --- a/activemodel/lib/active_model/model.rb +++ b/activemodel/lib/active_model/model.rb @@ -75,7 +75,7 @@ module ActiveModel # person = Person.new(name: 'bob', age: '18') # person.name # => "bob" # person.age # => "18" - def initialize(attributes={}) + def initialize(attributes = {}) assign_attributes(attributes) if attributes super() diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 840fc663c0..9532c63b65 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -173,7 +173,7 @@ module ActiveModel # BlogPost.model_name.human # => "Blog post" # # Specify +options+ with additional translating options. - def human(options={}) + def human(options = {}) return @human unless @klass.respond_to?(:lookup_ancestors) && @klass.respond_to?(:i18n_scope) diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb index b5e030a59b..a9d92eb92a 100644 --- a/activemodel/lib/active_model/serializers/json.rb +++ b/activemodel/lib/active_model/serializers/json.rb @@ -134,7 +134,7 @@ module ActiveModel # person.name # => "bob" # person.age # => 22 # person.awesome # => true - def from_json(json, include_root=include_root_in_json) + def from_json(json, include_root = include_root_in_json) hash = ActiveSupport::JSON.decode(json) hash = hash.values.first if include_root self.attributes = hash diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb index d8c5d929a3..ad78fd49ec 100644 --- a/activemodel/lib/active_model/type/helpers/time_value.rb +++ b/activemodel/lib/active_model/type/helpers/time_value.rb @@ -33,7 +33,7 @@ module ActiveModel def apply_seconds_precision(value) return value unless precision && value.respond_to?(:usec) number_of_insignificant_digits = 6 - precision - round_power = 10 ** number_of_insignificant_digits + round_power = 10**number_of_insignificant_digits value.change(usec: value.usec / round_power * round_power) end diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index df6d3f2bcb..8b815155b1 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -50,7 +50,7 @@ module ActiveModel define_callbacks :validate, scope: :name class_attribute :_validators, instance_writer: false - self._validators = Hash.new { |h,k| h[k] = [] } + self._validators = Hash.new { |h, k| h[k] = [] } end module ClassMethods diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index 4fadc795cd..9826c2fe9c 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -24,7 +24,7 @@ module ActiveModel class LazilyDefineAttributes < Module def initialize(attribute_definition) - define_method(:respond_to_missing?) do |method_name, include_private=false| + define_method(:respond_to_missing?) do |method_name, include_private = false| super(method_name, include_private) || attribute_definition.matches?(method_name) end diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index f73f16830f..de1524829e 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -6,7 +6,7 @@ module ActiveModel MESSAGES = { is: :wrong_length, minimum: :too_short, maximum: :too_long }.freeze CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze - RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :too_short, :too_long] + RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :too_short, :too_long] def initialize(options) if range = (options.delete(:in) || options.delete(:within)) diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 9c6065f61f..8212744170 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -104,7 +104,7 @@ module ActiveModel # Accepts options that will be made available through the +options+ reader. def initialize(options = {}) - @options = options.except(:class).freeze + @options = options.except(:class).freeze end # Returns the kind for this validator. |