Class: DTK::Shell::ContextEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/shell/domain/context_entity.rb

Constant Summary collapse

SHELL_SEPARATOR =
'/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alt_identifierObject

Returns the value of attribute alt_identifier.



23
24
25
# File 'lib/shell/domain/context_entity.rb', line 23

def alt_identifier
  @alt_identifier
end

#entityObject

Returns the value of attribute entity.



20
21
22
# File 'lib/shell/domain/context_entity.rb', line 20

def entity
  @entity
end

#identifierObject

Returns the value of attribute identifier.



22
23
24
# File 'lib/shell/domain/context_entity.rb', line 22

def identifier
  @identifier
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/shell/domain/context_entity.rb', line 21

def name
  @name
end

#shadow_entityObject

Returns the value of attribute shadow_entity.



24
25
26
# File 'lib/shell/domain/context_entity.rb', line 24

def shadow_entity
  @shadow_entity
end

Class Method Details

.create_context(context_name, entity_name, context_value = nil, type_id = :id, shadow_entity = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/shell/domain/context_entity.rb', line 28

def self.create_context(context_name, entity_name, context_value=nil, type_id=:id, shadow_entity=nil)
  if context_value
    if :id.eql?(type_id)
      return ContextEntity.create_identifier(context_name, entity_name, context_value, shadow_entity)
    else
      return ContextEntity.create_name_identifier(context_name, entity_name, context_value, shadow_entity)
    end
  else
    return ContextEntity.create_command(context_name, entity_name, shadow_entity)
  end
end

Instance Method Details

#get_identifier(type) ⇒ Object



52
53
54
# File 'lib/shell/domain/context_entity.rb', line 52

def get_identifier(type)
  return (type == 'id' ? self.identifier : self.name)
end

#is_alt_identifier?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/shell/domain/context_entity.rb', line 44

def is_alt_identifier?
  return !@alt_identifier.nil?
end

#is_command?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/shell/domain/context_entity.rb', line 48

def is_command?
  return @identifier.nil?
end

#is_identifier?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/shell/domain/context_entity.rb', line 40

def is_identifier?
  return !@identifier.nil?
end

#transform_alt_identifier_nameObject



56
57
58
# File 'lib/shell/domain/context_entity.rb', line 56

def transform_alt_identifier_name()
  @name.gsub(::DTK::Client::CommandBaseThor::ALT_IDENTIFIER_SEPARATOR, SHELL_SEPARATOR)
end