Class: OsUp::MigrationList
- Inherits:
-
Object
- Object
- OsUp::MigrationList
- Includes:
- Singleton
- Defined in:
- lib/osup/migration_list.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
protected
Returns the value of attribute index.
-
#migrations ⇒ Object
readonly
protected
Returns the value of attribute migrations.
Instance Method Summary collapse
- #[](id) ⇒ Object
- #count ⇒ Object
- #each ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ MigrationList
constructor
A new instance of MigrationList.
- #load_migrations ⇒ Object protected
Constructor Details
#initialize ⇒ MigrationList
Returns a new instance of MigrationList.
15 16 17 18 19 20 |
# File 'lib/osup/migration_list.rb', line 15 def initialize @migrations = [] @index = {} load_migrations end |
Instance Attribute Details
#index ⇒ Object (readonly, protected)
Returns the value of attribute index.
40 41 42 |
# File 'lib/osup/migration_list.rb', line 40 def index @index end |
#migrations ⇒ Object (readonly, protected)
Returns the value of attribute migrations.
40 41 42 |
# File 'lib/osup/migration_list.rb', line 40 def migrations @migrations end |
Instance Method Details
#[](id) ⇒ Object
22 23 24 |
# File 'lib/osup/migration_list.rb', line 22 def [](id) index[id] end |
#count ⇒ Object
30 31 32 |
# File 'lib/osup/migration_list.rb', line 30 def count migrations.count end |
#each ⇒ Object
26 27 28 |
# File 'lib/osup/migration_list.rb', line 26 def each(&) migrations.each(&) end |
#get ⇒ Object
34 35 36 |
# File 'lib/osup/migration_list.rb', line 34 def get migrations.clone end |
#load_migrations ⇒ Object (protected)
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/osup/migration_list.rb', line 42 def load_migrations dir = OsUp.migration_dir Dir.entries(dir).each do |f| next if f.start_with?('.') || !Dir.exist?(File.join(dir, f)) m = Migration.load(dir, f) migrations << m index[m.id] = m end migrations.sort! end |