Module: ZD
- Defined in:
- lib/zd.rb,
lib/zd/version.rb
Defined Under Namespace
Classes: Migration
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
- .[](name) ⇒ Object
- .add_dependency(migration, depends_on) ⇒ Object
- .dependencies ⇒ Object
- .load!(path) ⇒ Object
- .migrations ⇒ Object
- .register_migration(name, migration, dependencies) ⇒ Object
Instance Method Summary collapse
Class Method Details
.[](name) ⇒ Object
4 5 6 |
# File 'lib/zd.rb', line 4 def self.[](name) migrations[name] end |
.add_dependency(migration, depends_on) ⇒ Object
36 37 38 39 |
# File 'lib/zd.rb', line 36 def self.add_dependency(migration, depends_on) raise ArgumentError, "Dependency #{depends_on} not found for #{migration}" unless(depends_on == :nothing || self[depends_on]) dependencies[depends_on] << migration end |
.dependencies ⇒ Object
41 42 43 |
# File 'lib/zd.rb', line 41 def self.dependencies @dependencies ||= Hash.new{|h,k| h[k] = []} end |
.load!(path) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/zd.rb', line 12 def self.load!(path) Dir["#{path}/*.rb"].each do |e| if block_given? yield(e) else require e end end end |
.migrations ⇒ Object
22 23 24 |
# File 'lib/zd.rb', line 22 def self.migrations @migrations ||= {} end |
.register_migration(name, migration, dependencies) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/zd.rb', line 26 def self.register_migration(name, migration, dependencies) if dependencies.empty? raise ArgumentError, "You must declare migration dependencies (or pass :nothing)" end migrations[name] = migration dependencies.each do |d| add_dependency(name, d) end end |
Instance Method Details
#HANDLE(name) {|self[name]| ... } ⇒ Object
8 9 10 |
# File 'lib/zd.rb', line 8 def HANDLE(name) yield(self[name]) end |