Sha256: 4885412b1df761b955931ef1720de24b72d4cb3fe2b959173c54894747318b08

Contents?: true

Size: 989 Bytes

Versions: 32

Compression:

Stored size: 989 Bytes

Contents

module Effective
  module Resources
    module Naming
      SPLIT = /\/|::/  # / or ::

      def name # 'post'
        @name ||= (klass.try(:name).to_s.split(SPLIT).last || '').singularize.underscore
      end

      def plural_name # 'posts'
        name.pluralize
      end

      def initialized_name
        @initialized_name
      end

      def class_name # 'Effective::Post'
        @model_klass.try(:name).to_s
      end

      def class_path # 'effective'
        class_name.split('::')[0...-1].map { |name| name.underscore } * '/'
      end

      def namespaced_class_name # 'Admin::Effective::Post'
        (Array(namespaces).map { |name| name.classify } + [class_name]) * '::'
      end

      def namespace # 'admin/things'
        (namespaces.join('/') if namespaces.present?)
      end

      def namespaces # ['admin', 'things']
        @namespaces
      end

      def human_name
        class_name.gsub('::', ' ').underscore.gsub('_', ' ')
      end

    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
effective_resources-0.7.12 app/models/effective/resources/naming.rb
effective_resources-0.7.11 app/models/effective/resources/naming.rb
effective_resources-0.7.10 app/models/effective/resources/naming.rb
effective_resources-0.7.9 app/models/effective/resources/naming.rb
effective_resources-0.7.8 app/models/effective/resources/naming.rb
effective_resources-0.7.7 app/models/effective/resources/naming.rb
effective_resources-0.7.6 app/models/effective/resources/naming.rb
effective_resources-0.7.5 app/models/effective/resources/naming.rb
effective_resources-0.7.4 app/models/effective/resources/naming.rb
effective_resources-0.7.3 app/models/effective/resources/naming.rb
effective_resources-0.7.2 app/models/effective/resources/naming.rb
effective_resources-0.7.1 app/models/effective/resources/naming.rb
effective_resources-0.7.0 app/models/effective/resources/naming.rb
effective_resources-0.6.9 app/models/effective/resources/naming.rb
effective_resources-0.6.8 app/models/effective/resources/naming.rb
effective_resources-0.6.7 app/models/effective/resources/naming.rb
effective_resources-0.6.6 app/models/effective/resources/naming.rb
effective_resources-0.6.5 app/models/effective/resources/naming.rb
effective_resources-0.6.4 app/models/effective/resources/naming.rb
effective_resources-0.6.3 app/models/effective/resources/naming.rb