Module: LucidWorks::SimpleNaming
Instance Method Summary collapse
Instance Method Details
#model_name ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/lucid_works/simple_naming.rb', line 3 def model_name super.tap do |name| name.instance_eval do def singular; ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).tr('/', '_').freeze; end def plural; singular.pluralize.freeze; end def collection; ActiveSupport::Inflector.tableize(ActiveSupport::Inflector.demodulize(self)).freeze; end end end end |