Sha256: 416752f1035a500530ca2533aeb2dc6a905f0b2b843a1009b1c21104279f0d5f

Contents?: true

Size: 901 Bytes

Versions: 31

Compression:

Stored size: 901 Bytes

Contents

# encoding: utf-8
module RailsBestPractices
  module Core
    # Module container
    class Modules < Array
      # add module decendant.
      #
      # @param [String] module name
      # @param [String] decendant name
      def add_module_decendant(module_name, decendant)
        mod = find { |mod| mod.to_s == module_name }
        mod.add_decendant(decendant) if mod
      end
    end

    # Module info include module name and module spaces.
    class Mod
      attr_reader :decendants

      def initialize(module_name, modules)
        @module_name = module_name
        @modules = modules
        @decendants = []
      end

      def add_decendant(decendant)
        @decendants << decendant
      end

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

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
rails_best_practices-1.15.7 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.15.6 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.15.4 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.15.3 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.15.2 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.15.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.14.4 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.14.3 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.14.2 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.14.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.14.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.8 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.5 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.4 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.3 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.2 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.13.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.12.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.11.1 lib/rails_best_practices/core/modules.rb