Sha256: 5dc3fa639db3c359c3c8226b5f32dd52874cb39b87a0f6411db1da16d38ce7e4

Contents?: true

Size: 1.13 KB

Versions: 26

Compression:

Stored size: 1.13 KB

Contents

module Foobara
  class Command
    module Concerns
      module Namespace
        include Concern

        on_include do
          foobara_subclasses_are_namespaces!(default_parent: Foobara::GlobalDomain, autoregister: true)
        end

        module ClassMethods
          def type_for_declaration(...)
            domain.foobara_type_from_declaration(...)
          end

          def domain
            namespace = foobara_parent_namespace

            while namespace
              if namespace.is_a?(Module) && namespace.foobara_domain?
                d = namespace
                break
              end

              namespace = namespace.foobara_parent_namespace
            end

            d || GlobalDomain
          end

          # TODO: prefix these...
          def organization
            domain.foobara_organization
          end

          def full_command_name
            scoped_full_name
          end

          def full_command_symbol
            @full_command_symbol ||= Util.underscore_sym(full_command_name)
          end
        end

        foobara_delegate :type_for_declaration, to: :class
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/command/src/concerns/namespace.rb
foobara-0.0.25 projects/command/src/concerns/namespace.rb
foobara-0.0.24 projects/command/src/concerns/namespace.rb
foobara-0.0.23 projects/command/src/concerns/namespace.rb
foobara-0.0.22 projects/command/src/concerns/namespace.rb
foobara-0.0.21 projects/command/src/concerns/namespace.rb
foobara-0.0.20 projects/command/src/concerns/namespace.rb
foobara-0.0.19 projects/command/src/concerns/namespace.rb
foobara-0.0.18 projects/command/src/concerns/namespace.rb
foobara-0.0.17 projects/command/src/concerns/namespace.rb
foobara-0.0.16 projects/command/src/concerns/namespace.rb
foobara-0.0.15 projects/command/src/concerns/namespace.rb
foobara-0.0.14 projects/command/src/concerns/namespace.rb
foobara-0.0.13 projects/command/src/concerns/namespace.rb
foobara-0.0.12 projects/command/src/concerns/namespace.rb
foobara-0.0.11 projects/command/src/concerns/namespace.rb
foobara-0.0.10 projects/command/src/concerns/namespace.rb
foobara-0.0.9 projects/command/src/concerns/namespace.rb
foobara-0.0.8 projects/command/src/concerns/namespace.rb
foobara-0.0.7 projects/command/src/concerns/namespace.rb