Class: ActiveScaffold::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Bridge

Returns a new instance of Bridge.



12
13
14
15
16
17
18
19
20
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 12

def initialize(name, &block)
  self.name = name
  @install = nil
  # by convention and default, use the bridge name as the required constant for installation
  @install_if = lambda { Object.const_defined?(name) }
  self.instance_eval(&block)
  
  ActiveScaffold::Bridge.bridges << self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 7

def name
  @name
end

Class Method Details

.run_allObject



38
39
40
41
42
43
44
45
46
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 38

def self.run_all
  return false if self.bridges_run
  ActiveScaffold::Bridge.bridges.each{|bridge|
    bridge.run
  }
  
  
  self.bridges_run=true
end

Instance Method Details

#install(&block) ⇒ Object

Set the install block



23
24
25
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 23

def install(&block)
  @install = block
end

#install?(&block) ⇒ Boolean

Set the install_if block (to check to see whether or not to install the block)

Returns:

  • (Boolean)


28
29
30
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 28

def install?(&block)
  @install_if = block
end

#runObject

Raises:

  • (ArgumentError)


33
34
35
36
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb', line 33

def run
  raise(ArgumentError, "install and install? not defined for bridge #{name}" ) unless @install && @install_if
  @install.call if @install_if.call
end