Module: Dynomite::Item::TableNamespace

Defined in:
lib/dynomite/item/table_namespace.rb

Instance Method Summary collapse

Instance Method Details

#get_namespaceObject



30
31
32
33
# File 'lib/dynomite/item/table_namespace.rb', line 30

def get_namespace
  return @namespace if defined?(@namespace)
  @namespace = Dynomite.config.namespace || Dynomite.config.default_namespace
end

#get_table_nameObject



16
17
18
19
# File 'lib/dynomite/item/table_namespace.rb', line 16

def get_table_name
  @table_name ||= self.name.pluralize.gsub('::','_').underscore
  [namespace, @table_name].reject {|s| s.nil? || s.empty?}.join(namespace_separator)
end

#namespace(*args) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/dynomite/item/table_namespace.rb', line 21

def namespace(*args)
  case args.size
  when 0
    get_namespace
  when 1
    set_namespace(args[0])
  end
end

#namespace_separatorObject



39
40
41
# File 'lib/dynomite/item/table_namespace.rb', line 39

def namespace_separator
  Dynomite.config.namespace_separator || '_'
end

#set_namespace(value) ⇒ Object



35
36
37
# File 'lib/dynomite/item/table_namespace.rb', line 35

def set_namespace(value)
  @namespace = value
end

#set_table_name(value) ⇒ Object



12
13
14
# File 'lib/dynomite/item/table_namespace.rb', line 12

def set_table_name(value)
  @table_name = value
end

#table_name(*args) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/dynomite/item/table_namespace.rb', line 3

def table_name(*args)
  case args.size
  when 0
    get_table_name
  when 1
    set_table_name(args[0])
  end
end