Skip to content

Commit

Permalink
Rename config option
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegeek committed Aug 7, 2023
1 parent 2ad48c4 commit 52a7329
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/encoded_id/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Configuration
:group_separator,
:alphabet,
:id_length,
:slug_method_name,
:slug_value_method_name,
:slugged_id_separator,
:annotation_method_name, # Set to nil to disable annotated IDs
:annotated_id_separator
Expand All @@ -19,7 +19,7 @@ def initialize
@group_separator = "-"
@alphabet = ::EncodedId::Alphabet.modified_crockford
@id_length = 8
@slug_method_name = :name_for_encoded_id_slug
@slug_value_method_name = :name_for_encoded_id_slug
@slugged_id_separator = "--"
@annotation_method_name = :annotation_for_encoded_id
@annotated_id_separator = "_"
Expand Down
2 changes: 1 addition & 1 deletion lib/encoded_id/rails/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def encoded_id
def slugged_encoded_id
return unless id
return @slugged_encoded_id if defined?(@slugged_encoded_id) && !id_changed?
with = EncodedId::Rails.configuration.slug_method_name
with = EncodedId::Rails.configuration.slug_value_method_name
separator = EncodedId::Rails.configuration.slugged_id_separator
encoded = encoded_id
return unless encoded
Expand Down
2 changes: 1 addition & 1 deletion sig/encoded_id/rails.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module EncodedId
attr_accessor character_group_size: ::Integer
attr_accessor alphabet: ::EncodedId::Alphabet
attr_accessor id_length: ::Integer
attr_accessor slug_method_name: ::Symbol
attr_accessor slug_value_method_name: ::Symbol
attr_accessor slugged_id_separator: ::String
attr_accessor annotation_method_name: ::Symbol
attr_accessor annotated_id_separator: ::String
Expand Down
4 changes: 2 additions & 2 deletions test/encoded_id/test_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_that_it_has_a_version_number

def setup
@model = MyModel.create
EncodedId::Rails.configuration.slug_method_name = :custom_slug_method
EncodedId::Rails.configuration.slug_value_method_name = :custom_slug_method
end

def test_find_by_encoded_id_gets_model_given_encoded_id
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_encoded_id_is_recalculated_if_id_changes

def test_it_does_not_slug_encoded_id_for_model_with_no_slug
assert_raises(StandardError) do
EncodedId::Rails.configuration.slug_method_name = :name_for_encoded_id_slug
EncodedId::Rails.configuration.slug_value_method_name = :name_for_encoded_id_slug
model.slugged_encoded_id
end
end
Expand Down

0 comments on commit 52a7329

Please sign in to comment.