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.11.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.10.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-gorgeouscode-1.0.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.10.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.9.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.9.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.8.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.7.2 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.7.1 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.7.0 lib/rails_best_practices/core/modules.rb
rails_best_practices-1.6.0 lib/rails_best_practices/core/modules.rb