Sha256: 6b947f22ee9db4068ef933562dbe2ef6037f6b0b1fbee0c5b3b6aa77cdab7f54
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
require "English" module Foobara module Generators module CommandGenerator class CommandConfig < Foobara::Model attributes do name :string, :required description :string, :allow_nil organization_name :string, :allow_nil domain_name :string, :allow_nil no_organization :boolean, default: false no_domain :boolean, default: false end attr_accessor :command_path, :full_module_name, :original_attributes def initialize(...) super update_names end def module_path @module_path ||= full_module_name.split("::") end def command_name @command_name ||= command_path.join("::") end def full_module_path @full_module_path ||= full_module_name.split("::") end private def update_names return if @names_updated self.original_attributes = Util.deep_dup(attributes) org, *dom_command_parts = name.split("::") if !no_organization && organization_name.nil? write_attribute(:organization_name, org) else dom_command_parts = [org, *dom_command_parts] end dom, *command_parts = dom_command_parts if !no_domain && domain_name.nil? write_attribute(:domain_name, dom) else command_parts = [dom, *command_parts] end self.command_path = command_parts self.full_module_name = [*organization_name, *domain_name, *command_parts].join("::") @names_updated = true end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
foobara-command-generator-0.0.3 | src/command_config.rb |
foobara-command-generator-0.0.2 | src/command_config.rb |
foobara-command-generator-0.0.1 | src/command_config.rb |