Class: ActiveScaffold::Bridge
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/bridge.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, &block) ⇒ Bridge
constructor
A new instance of Bridge.
-
#install(&block) ⇒ Object
Set the install block.
-
#install?(&block) ⇒ Boolean
Set the install_if block (to check to see whether or not to install the block).
- #run ⇒ Object
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
#name ⇒ Object
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_all ⇒ Object
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)
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 |
#run ⇒ Object
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 |