Sha256: 09092311f981d850201b44b4eb7ffd0101d289727627958aa53e8b3f48566c03

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8
module RailsBestPractices
  module Core
    # Klass container.
    class Klasses < Array
      # If include the class.
      #
      # @param [String] class name
      # @return [Boolean] include or not
      def include?(class_name)
        find { |klass| klass.to_s == class_name }
      end
    end

    # Class info includes class name, extend class name and module names.
    class Klass
      def initialize(class_name, extend_class_name, modules)
        @class_name = class_name
        @extend_class_name = extend_class_name
        @modules = modules.dup
      end

      def class_name
        if @modules.empty?
          @class_name
        else
          @modules.map { |modu| "#{modu}::" }.join("") + @class_name
        end
      end

      def extend_class_name
        if @modules.empty?
          @extend_class_name
        else
          @modules.map { |modu| "#{modu}::" }.join("") + @extend_class_name
        end
      end

      def to_s
        class_name
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-1.15.2 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.15.1 lib/rails_best_practices/core/klasses.rb