Sha256: ba05895c2b7e060f053366fe661fee3c83a7860fcef00b66c756894ce400ce98

Contents?: true

Size: 831 Bytes

Versions: 6

Compression:

Stored size: 831 Bytes

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
      attr_reader :class_name, :extend_class_name

      def initialize(class_name, extend_class_name, modules)
        @class_name = class_name
        @extend_class_name = extend_class_name
        @modules = modules.dup
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.14.3 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.14.2 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.14.1 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.14.0 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.13.8 lib/rails_best_practices/core/klasses.rb