Sha256: 921635d8965c371565f96096f2405ceb741da924ebb218dd0cd375d379861e35

Contents?: true

Size: 862 Bytes

Versions: 16

Compression:

Stored size: 862 Bytes

Contents

module Administrate
  class ResourceResolver
    def initialize(controller_path)
      @controller_path = controller_path
    end

    def dashboard_class
      ActiveSupport::Inflector.constantize("#{resource_class_name}Dashboard")
    end

    def namespace
      controller_path.split("/").first
    end

    def resource_class
      ActiveSupport::Inflector.constantize(resource_class_name)
    end

    def resource_name
      model_path_parts.map(&:underscore).join("__").to_sym
    end

    def resource_title
      model_path_parts.join(" ")
    end

    private

    def resource_class_name
      model_path_parts.join("::")
    end

    def model_path_parts
      controller_path_parts.map(&:camelize)
    end

    def controller_path_parts
      controller_path.split("/")[1..-1].map(&:singularize)
    end

    attr_reader :controller_path
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
administrate-0.14.0 lib/administrate/resource_resolver.rb
viniBaxterDesk-22.0.0 lib/administrate/resource_resolver.rb
viniBaxterDesk-0.21.0 lib/administrate/resource_resolver.rb
viniBaxterDesk-0.20.0 lib/administrate/resource_resolver.rb
viniBaxterDesk-0.14.0 lib/administrate/resource_resolver.rb
viniBaxterDesk-0.13.2 lib/administrate/resource_resolver.rb
viniBaxterDesk-0.13.1 lib/administrate/resource_resolver.rb
administrate-0.13.0 lib/administrate/resource_resolver.rb
administrate-0.12.0 lib/administrate/resource_resolver.rb
administrate-0.11.0 lib/administrate/resource_resolver.rb
semantic-administrate-0.10.1 lib/administrate/resource_resolver.rb
semantic-administrate-0.10.0 lib/administrate/resource_resolver.rb
administrate-0.10.0 lib/administrate/resource_resolver.rb
semantic-administrate-0.1.1 lib/administrate/resource_resolver.rb
administrate-0.9.0 lib/administrate/resource_resolver.rb
semantic-administrate-0.1.0 lib/administrate/resource_resolver.rb