Sha256: 7bcaa6f4573ffab47a8b60c600a04df03292a6a6d145159ec87093e6892a9c4f

Contents?: true

Size: 921 Bytes

Versions: 5

Compression:

Stored size: 921 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
      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
        @modules.map { |modu| "#{modu}::" }.join("") + @class_name
      end

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

      def to_s
        class_name
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_best_practices-1.16.0 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.15.7 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.15.6 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.15.4 lib/rails_best_practices/core/klasses.rb
rails_best_practices-1.15.3 lib/rails_best_practices/core/klasses.rb