Sha256: dd3835fdae9de833c6d42b1904a9cda84241e7c9aa361800185cf579eac43a73

Contents?: true

Size: 634 Bytes

Versions: 17

Compression:

Stored size: 634 Bytes

Contents

module ActiveSupport
  class ModelName < String
    attr_reader :singular, :plural, :cache_key, :partial_path

    def initialize(name)
      super
      @singular = underscore.tr('/', '_').freeze
      @plural = @singular.pluralize.freeze
      @cache_key = tableize.freeze
      @partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze
    end
  end

  module CoreExtensions
    module Module
      # Returns an ActiveSupport::ModelName object for module. It can be
      # used to retrieve all kinds of naming-related information.
      def model_name
        @model_name ||= ModelName.new(name)
      end
    end
  end
end

Version data entries

17 entries across 16 versions & 10 rubygems

Version Path
p8-castronaut-0.6.1.1 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
relevance-castronaut-0.6.0 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
relevance-castronaut-0.6.1 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
relevance-castronaut-0.7.4 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
relevance-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
nbudin-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb
factorylabs-castronaut-0.7.5 vendor/activesupport/lib/active_support/core_ext/module/model_naming.rb
activesupport-2.2.3 lib/active_support/core_ext/module/model_naming.rb
webroar-0.2.2 src/admin_panel/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb
activesupport-2.3.2 lib/active_support/core_ext/module/model_naming.rb
activesupport-2.2.2 lib/active_support/core_ext/module/model_naming.rb
mack-active_record-0.8.2 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb
mack-facets-0.8.3 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb
mack-facets-0.8.3.1 lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb
radiant-0.8.0 vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb