lib/jets/inflections.rb in jets-0.10.4 vs lib/jets/inflections.rb in jets-1.0.0
- old
+ new
@@ -1,23 +1,31 @@
module Jets
class Inflections
class << self
def load!
ActiveSupport::Inflector.inflections(:en) do |inflect|
- base_inflections.each do |k,v|
- inflect.irregular k,v
- end
- # Users can add custom inflections
- Jets.config.inflections.irregular.each do |k,v|
- inflect.irregular k,v
- end
+ load(inflect, base)
+ load(inflect, custom)
end
end
- def base_inflections
+ def load(inflect, inflections)
+ inflections.each do |k,v|
+ inflect.irregular k,v
+ end
+ end
+
+ # base custom inflections
+ def base
{
sns: 'sns'
}
+ end
+
+ # User defined custom inflections
+ def custom
+ path = "#{Jets.root}config/inflections.yml"
+ File.exist?(path) ? YAML.load_file(path) : {}
end
end
end
end