Class: TCB::DomainContext

Inherits:
Object
  • Object
show all
Defined in:
lib/tcb/domain_context.rb

Constant Summary collapse

NAMESPACE_SEPARATOR =
"/"
TABLE_SEPARATOR =
"__"
TABLE_SUFFIX =
"_events"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_module(domain_module) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/tcb/domain_context.rb', line 9

def self.from_module(domain_module)
  value = domain_module.name
    .gsub("::", NAMESPACE_SEPARATOR)
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .downcase

  new(value: value)
end

Instance Method Details

#table_nameObject



23
24
25
26
27
# File 'lib/tcb/domain_context.rb', line 23

def table_name
  value
    .gsub(NAMESPACE_SEPARATOR, TABLE_SEPARATOR)
    .concat(TABLE_SUFFIX)
end

#to_sObject



19
20
21
# File 'lib/tcb/domain_context.rb', line 19

def to_s
  value
end