开发者

Convention For Gem with Common Name

开发者 https://www.devze.com 2023-04-08 04:56 出处:网络
I recently authored a gem called \'setting\' (found here). The extends ActiveRecord with a module named \'Setting\'. I understand that gems are supposed to use the namespace they are named, however wh

I recently authored a gem called 'setting' (found here). The extends ActiveRecord with a module named 'Setting'. I understand that gems are supposed to use the namespace they are named, however when testing this caused collisions with ActiveRecord models with the same name (a Setting model). Does a standard exist for creating a private module namespace? I don't need users of the gem to ever access the module outside the extension in ActiveRecord. Do I have any o开发者_StackOverflow社区ptions outside of picking a less common name?


Since you're writing an Active Record extension, you could place your module inside the ActiveRecord namespace:

module ActiveRecord
  module Setting
  end
end

Other than that, no, there's no practical namespace solution for gems with very common names.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号