Skip to content

Commit

Permalink
Replace **options with ** where options is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Mar 3, 2017
1 parent 326a097 commit e4dcc79
Show file tree
Hide file tree
Showing 24 changed files with 42 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/mobility/backend/active_model/dirty.rb
Expand Up @@ -23,7 +23,7 @@ module Backend
module ActiveModel::Dirty
# @!group Backend Accessors
# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
locale_accessor = "#{attribute}_#{locale}"
if model.changed_attributes.has_key?(locale_accessor) && model.changed_attributes[locale_accessor] == value
model.attributes_changed_by_setter.except!(locale_accessor)
Expand All @@ -43,7 +43,7 @@ def self.included(backend_class)
# methods for translated attributes onto model class.
module ClassMethods
# (see Mobility::Backend::Setup#setup_model)
def setup_model(model_class, attributes, **options)
def setup_model(model_class, attributes, **)
super
model_class.class_eval do
%w[changed? change was will_change! previously_changed? previous_change].each do |suffix|
Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/active_record/hash_valued.rb
Expand Up @@ -11,12 +11,12 @@ class ActiveRecord::HashValued
# @!group Backend Accessors
#
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translations[locale]
end

# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
translations[locale] = value
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/active_record/hstore.rb
Expand Up @@ -18,7 +18,7 @@ class ActiveRecord::Hstore < ActiveRecord::HashValued

# @!group Backend Accessors
# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
translations[locale] = value && value.to_s
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/active_record/hstore/query_methods.rb
@@ -1,7 +1,7 @@
module Mobility
module Backend
class ActiveRecord::Hstore::QueryMethods < ActiveRecord::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor

Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/active_record/jsonb/query_methods.rb
@@ -1,7 +1,7 @@
module Mobility
module Backend
class ActiveRecord::Jsonb::QueryMethods < ActiveRecord::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor

Expand Down
6 changes: 3 additions & 3 deletions lib/mobility/backend/active_record/key_value.rb
Expand Up @@ -28,19 +28,19 @@ class ActiveRecord::KeyValue

# @!macro backend_constructor
# @option options [Symbol] association_name Name of association
def initialize(model, attribute, **options)
def initialize(model, attribute, **)
super
@association_name = options[:association_name]
end

# @!group Backend Accessors
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translation_for(locale).value
end

# @!macro backend_reader
def write(locale, value, **options)
def write(locale, value, **)
translation_for(locale).tap { |t| t.value = value }.value
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/active_record/query_methods.rb
Expand Up @@ -10,7 +10,7 @@ module ActiveRecord
class QueryMethods < Module
# @param [Array<String>] attributes Translated attributes
# @param [Hash] options Backend options
def initialize(attributes, **options)
def initialize(attributes, **)
@attributes = attributes
@attributes_extractor = lambda do |opts|
opts.is_a?(Hash) && (opts.keys.map(&:to_s) & attributes).presence
Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/active_record/serialized.rb
Expand Up @@ -28,12 +28,12 @@ class ActiveRecord::Serialized
# @!group Backend Accessors
#
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translations[locale]
end

# @!macro backend_reader
def write(locale, value, **options)
def write(locale, value, **)
translations[locale] = value
end
# @!endgroup
Expand Down
@@ -1,7 +1,7 @@
module Mobility
module Backend
class ActiveRecord::Serialized::QueryMethods < ActiveRecord::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor
opts_checker = @opts_checker = lambda do |opts|
Expand Down
6 changes: 3 additions & 3 deletions lib/mobility/backend/active_record/table.rb
Expand Up @@ -82,19 +82,19 @@ class ActiveRecord::Table

# @!macro backend_constructor
# @option options [Symbol] association_name Name of association
def initialize(model, attribute, **options)
def initialize(model, attribute, **)
super
@association_name = options[:association_name]
end

# @!group Backend Accessors
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translation_for(locale).send(attribute)
end

# @!macro backend_reader
def write(locale, value, **options)
def write(locale, value, **)
translation_for(locale).tap { |t| t.send("#{attribute}=", value) }.send(attribute)
end
# @!endgroup
Expand Down
6 changes: 3 additions & 3 deletions lib/mobility/backend/cache.rb
Expand Up @@ -35,7 +35,7 @@ module Backend
module Cache
# @group Backend Accessors
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
if write_to_cache? || cache.has_key?(locale)
cache[locale]
else
Expand All @@ -44,7 +44,7 @@ def read(locale, **options)
end

# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
cache[locale] = write_to_cache? ? value : super
end
# @!endgroup
Expand All @@ -57,7 +57,7 @@ module Setup
# @param model_class Model class
# @param [Array<String>] attributes Backend attributes
# @param [Hash] options Backend options
def setup_model(model_class, attributes, **options)
def setup_model(model_class, attributes, **)
super
model_class.include BackendResetter.for(model_class).new(attributes) { clear_cache }
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/column.rb
Expand Up @@ -22,12 +22,12 @@ module Column
# @!group Backend Accessors
#
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
model.send(column(locale))
end

# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
model.send("#{column(locale)}=", value)
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/column/query_methods.rb
@@ -1,7 +1,7 @@
module Mobility
module Backend
class Sequel::Column::QueryMethods < Backend::Sequel::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor

Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/sequel/dirty.rb
Expand Up @@ -10,7 +10,7 @@ module Backend
module Sequel::Dirty
# @!group Backend Accessors
# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
locale_accessor = "#{attribute}_#{locale}".to_sym
if model.column_changes.has_key?(locale_accessor) && model.initial_values[locale_accessor] == value
super
Expand All @@ -31,7 +31,7 @@ def self.included(backend_class)
# methods for translated attributes onto model class.
module ClassMethods
# (see Mobility::Backend::Setup#setup_model)
def setup_model(model_class, attributes, **options)
def setup_model(model_class, attributes, **)
super
model_class.class_eval do
mod = Module.new do
Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/sequel/hash_valued.rb
Expand Up @@ -9,12 +9,12 @@ class Sequel::HashValued
include Backend

# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translations[locale.to_s]
end

# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
translations[locale.to_s] = value
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/hstore.rb
Expand Up @@ -18,7 +18,7 @@ class Sequel::Hstore < Sequel::HashValued

# @!group Backend Accessors
# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
translations[locale.to_s] = value && value.to_s
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/hstore/query_methods.rb
Expand Up @@ -3,7 +3,7 @@
module Mobility
module Backend
class Sequel::Hstore::QueryMethods < Sequel::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor

Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/jsonb/query_methods.rb
Expand Up @@ -3,7 +3,7 @@
module Mobility
module Backend
class Sequel::Jsonb::QueryMethods < Sequel::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor

Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/sequel/key_value.rb
Expand Up @@ -31,12 +31,12 @@ def initialize(model, attribute, **options)

# @!group Backend Accessors
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translation_for(locale).value
end

# @!macro backend_writer
def write(locale, value, **options)
def write(locale, value, **)
translation_for(locale).tap { |t| t.value = value }.value
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/query_methods.rb
Expand Up @@ -10,7 +10,7 @@ module Sequel
class QueryMethods < Module
# @param [Array<String>] attributes Translated attributes
# @param [Hash] options Backend options
def initialize(attributes, **options)
def initialize(attributes, **)
@attributes = attributes.map! &:to_sym
@attributes_extractor = lambda do |cond|
cond.is_a?(Hash) && (cond.keys & attributes).presence
Expand Down
4 changes: 2 additions & 2 deletions lib/mobility/backend/sequel/serialized.rb
Expand Up @@ -35,12 +35,12 @@ class Sequel::Serialized
# @!group Backend Accessors
#
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translations[locale]
end

# @!macro backend_reader
def write(locale, value, **options)
def write(locale, value, **)
translations[locale] = value
end
# @!endgroup
Expand Down
2 changes: 1 addition & 1 deletion lib/mobility/backend/sequel/serialized/query_methods.rb
@@ -1,7 +1,7 @@
module Mobility
module Backend
class Sequel::Serialized::QueryMethods < Sequel::QueryMethods
def initialize(attributes, **options)
def initialize(attributes, **)
super
attributes_extractor = @attributes_extractor
cond_checker = @cond_checker = lambda do |cond|
Expand Down
6 changes: 3 additions & 3 deletions lib/mobility/backend/sequel/table.rb
Expand Up @@ -15,19 +15,19 @@ class Sequel::Table

# @!macro backend_constructor
# @option options [Symbol] association_name Name of association
def initialize(model, attribute, **options)
def initialize(model, attribute, **)
super
@association_name = options[:association_name]
end

# @!group Backend Accessors
# @!macro backend_reader
def read(locale, **options)
def read(locale, **)
translation_for(locale).send(attribute)
end

# @!macro backend_reader
def write(locale, value, **options)
def write(locale, value, **)
translation_for(locale).tap { |t| t.send("#{attribute}=", value) }.send(attribute)
end

Expand Down
3 changes: 3 additions & 0 deletions spec/support/shared_examples/accessor_examples.rb
Expand Up @@ -36,7 +36,10 @@
Mobility.with_locale(:ja) do
expect(instance.public_send(attribute1)).to eq("あああ")
expect(instance.public_send(attribute2)).to eq(nil)
expect(instance.public_send(attribute1, { locale: :en })).to eq("foo")
expect(instance.public_send(attribute2, { locale: :en })).to eq("bar")
end
expect(instance.public_send(attribute1, { locale: :ja })).to eq("あああ")
end

instance.save
Expand Down

0 comments on commit e4dcc79

Please sign in to comment.