Class: ActiveScaffold::Bridges::Bridge
- Defined in:
- lib/active_scaffold/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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 13 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::Bridges::Bridge.bridges << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 8 def name @name end |
Class Method Details
.run_all ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 39 def self.run_all return false if self.bridges_run ActiveScaffold::Bridges::Bridge.bridges.each{|bridge| bridge.run } self.bridges_run=true end |
Instance Method Details
#install(&block) ⇒ Object
Set the install block
24 25 26 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 24 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)
29 30 31 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 29 def install?(&block) @install_if = block end |
#run ⇒ Object
34 35 36 37 |
# File 'lib/active_scaffold/bridges/bridge.rb', line 34 def run raise(ArgumentError, "install and install? not defined for bridge #{name}" ) unless @install && @install_if @install.call if @install_if.call end |