Class: Straitjacket::Proxy

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

Instance Method Summary collapse

Constructor Details

#initialize(inner, table) ⇒ Proxy

Returns a new instance of Proxy.



7
8
9
10
# File 'lib/straitjacket.rb', line 7

def initialize(inner, table)
  @inner = inner
  @table = table
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



12
13
14
15
# File 'lib/straitjacket.rb', line 12

def method_missing(method)
  @name = method
  self
end

Instance Method Details

#check(statement, options = {}) ⇒ Object



23
24
25
# File 'lib/straitjacket.rb', line 23

def check(statement, options = {})
  add_constraint CheckConstraint.new(@table, statement, named(options))
end

#deprecated(*names) ⇒ Object



17
18
19
20
21
# File 'lib/straitjacket.rb', line 17

def deprecated(*names)
  (names << @name).each do |name|
    add_constraint DeprecatedConstraint.new(@table, name)
  end
end

#foreign_key(column, options = {}) ⇒ Object



27
28
29
# File 'lib/straitjacket.rb', line 27

def foreign_key(column, options = {})
  add_constraint ForeignKeyConstraint.new(@table, nil, named(options).merge(:column => column))
end