Class: Straitjacket

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

Defined Under Namespace

Classes: CheckConstraint, Constraint, DeprecatedConstraint, Error, ForeignKeyConstraint, Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Straitjacket

Returns a new instance of Straitjacket.



52
53
54
55
56
# File 'lib/straitjacket.rb', line 52

def initialize(&block)
  @constraints = []
  @names = {}
  instance_eval(&block) if block
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints.



50
51
52
# File 'lib/straitjacket.rb', line 50

def constraints
  @constraints
end

Instance Method Details

#apply(conn) ⇒ Object



58
59
60
# File 'lib/straitjacket.rb', line 58

def apply(conn)
  constraints.map{|c| c.apply(conn) }
end

#on(table, &block) ⇒ Object



62
63
64
65
66
# File 'lib/straitjacket.rb', line 62

def on(table, &block)
  proxy = Proxy.new(self, table)
  proxy.instance_eval(&block) if block
  proxy
end