Module: Dddr::Sequel::ClassMethods

Defined in:
lib/dddr/sequel.rb

Instance Method Summary collapse

Instance Method Details

#const_missing(name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/dddr/sequel.rb', line 30

def const_missing(name)
  if name == :Repository
    create_repository_for(self)
  else
    super
  end
end

#create_properties(*names) ⇒ Object



8
9
10
11
12
# File 'lib/dddr/sequel.rb', line 8

def create_properties(*names)
  names.flatten.each do |name|
    attr_accessor name
  end
end

#from_row(row) ⇒ Object



14
15
16
17
18
# File 'lib/dddr/sequel.rb', line 14

def from_row(row)
  item = new
  item.from_hash(row[:uid], row)
  item
end

#queries(&block) ⇒ Object



25
26
27
28
# File 'lib/dddr/sequel.rb', line 25

def queries(&block)
  @queries_module ||= Module.new
  @queries_module.module_eval(&block)
end

#table(name = nil) ⇒ Object



20
21
22
23
# File 'lib/dddr/sequel.rb', line 20

def table(name = nil)
  @table_name = name unless name.nil?
  @table_name
end