Module: Alf::Support::Bindable

Included in:
Algebra::Operand
Defined in:
lib/alf-support/alf/support/bindable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



5
6
7
# File 'lib/alf-support/alf/support/bindable.rb', line 5

def connection
  @connection
end

Instance Method Details

#bind(connection) ⇒ Object



8
9
10
11
12
13
# File 'lib/alf-support/alf/support/bindable.rb', line 8

def bind(connection)
  dup.tap{|c|
    c.connection = connection
    yield(c) if block_given?
  }
end

#bound?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/alf-support/alf/support/bindable.rb', line 15

def bound?
  defined?(@connection) && !@connection.nil?
end

#connection!Object

Raises:



19
20
21
22
# File 'lib/alf-support/alf/support/bindable.rb', line 19

def connection!
  raise UnboundError unless bound?
  @connection
end