parent
0b342ec0d4
commit
34a61e62d0
@ -0,0 +1,39 @@ |
||||
module OpenProject |
||||
class Inflector < Zeitwerk::GemInflector |
||||
alias_method :default_inflect, :camelize |
||||
|
||||
def camelize(basename, abspath) |
||||
self.class.camelize_rules.each do |rule| |
||||
name = instance_exec(basename, abspath, &rule) |
||||
|
||||
return name if name |
||||
end |
||||
|
||||
super |
||||
end |
||||
|
||||
private |
||||
|
||||
def overrides |
||||
self.class.inflections.merge(super) |
||||
end |
||||
|
||||
class << self |
||||
def rule(&block) |
||||
camelize_rules << block |
||||
end |
||||
|
||||
def camelize_rules |
||||
@camelize_rules ||= [] |
||||
end |
||||
|
||||
def inflections |
||||
@inflections ||= {} |
||||
end |
||||
|
||||
def inflection(overrides) |
||||
inflections.merge!(overrides) |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue