Module: Dbee::Dsl::Methods

Included in:
Base
Defined in:
lib/dbee/dsl/methods.rb

Overview

This mixin contains all the reader/writers for model meta-data declared through the DSL.

Instance Method Summary collapse

Instance Method Details

#association(name, opts = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/dbee/dsl/methods.rb', line 34

def association(name, opts = {})
  value =
    if opts.is_a?(Dsl::Association)
      opts
    else
      Dsl::Association.new(self.name, inflector, name, opts)
    end

  tap { associations_by_name[name.to_s] = value }
end

#associations_by_nameObject



49
50
51
# File 'lib/dbee/dsl/methods.rb', line 49

def associations_by_name
  @associations_by_name ||= {}
end

#child(name, opts = {}) ⇒ Object



28
29
30
31
32
# File 'lib/dbee/dsl/methods.rb', line 28

def child(name, opts = {})
  association = association_builder.child_association(self.name, name, opts)

  association(name, association)
end

#parent(name, opts = {}) ⇒ Object



22
23
24
25
26
# File 'lib/dbee/dsl/methods.rb', line 22

def parent(name, opts = {})
  association = association_builder.parent_association(self.name, name, opts)

  association(name, association)
end

#partitioner(name, value) ⇒ Object



14
15
16
# File 'lib/dbee/dsl/methods.rb', line 14

def partitioner(name, value)
  partitioners << { name: name, value: value }
end

#partitionersObject



53
54
55
# File 'lib/dbee/dsl/methods.rb', line 53

def partitioners
  @partitioners ||= []
end

#table(name) ⇒ Object



18
19
20
# File 'lib/dbee/dsl/methods.rb', line 18

def table(name)
  tap { @table_name = name.to_s }
end

#table_nameObject



45
46
47
# File 'lib/dbee/dsl/methods.rb', line 45

def table_name
  @table_name || ''
end

#table_name?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/dbee/dsl/methods.rb', line 57

def table_name?
  !table_name.empty?
end