Skip to content

Commit

Permalink
Use ROM::Inflector consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jan 21, 2025
1 parent e4b80ff commit 6b443d2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rom/factory/attributes/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def call(attrs = EMPTY_HASH, parent, persist: true)
if persist
builder.persistable.create(*traits, **association_hash)
else
belongs_to_name = Dry::Core::Inflector.singularize(assoc.source_alias)
belongs_to_name = ::ROM::Inflector.singularize(assoc.source_alias)
belongs_to_associations = {belongs_to_name.to_sym => parent}
final_attrs = attrs.merge(association_hash).merge(belongs_to_associations)
builder.struct(*traits, **final_attrs)
Expand Down Expand Up @@ -161,7 +161,7 @@ def call(attrs = EMPTY_HASH, parent, persist: true)
if through_factory?
structs.each do |child|
through_attrs = {
::Dry::Core::Inflector.singularize(assoc.source.name.key).to_sym => parent,
::ROM::Inflector.singularize(assoc.source.name.key).to_sym => parent,
assoc.through.assoc_name => child
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rom/factory/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def fake(*args, unique: false, **options)
*ns, method_name = args

const = ns.reduce(::Faker) do |obj, name|
obj.const_get(::Dry::Core::Inflector.camelize(name))
obj.const_get(::ROM::Inflector.camelize(name))
end

if unique
Expand Down
4 changes: 2 additions & 2 deletions lib/rom/factory/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ def for_relation(relation)

# @api private
def infer_factory_name(name)
::Dry::Core::Inflector.singularize(name).to_sym
::ROM::Inflector.singularize(name).to_sym
end

# @api private
def infer_relation(name)
::Dry::Core::Inflector.pluralize(name).to_sym
::ROM::Inflector.pluralize(name).to_sym
end

# @api private
Expand Down
2 changes: 1 addition & 1 deletion lib/rom/factory/tuple_evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def next_id

def select_mergeable_attrs(traits, attrs)
unmergeable = assocs(traits).select(&:through?).map do |a|
Dry::Core::Inflector.singularize(a.assoc.target.name.to_sym).to_sym
::ROM::Inflector.singularize(a.assoc.target.name.to_sym).to_sym
end
attrs.dup.delete_if { |key, _| unmergeable.include?(key) }
end
Expand Down

0 comments on commit 6b443d2

Please sign in to comment.