Class: GoodMigrations::MigrationDetails
- Inherits:
-
Object
- Object
- GoodMigrations::MigrationDetails
- Defined in:
- lib/good_migrations/migration_details.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #associated_time ⇒ Object
- #considered_before?(time) ⇒ Boolean
-
#initialize(path) ⇒ MigrationDetails
constructor
A new instance of MigrationDetails.
Constructor Details
#initialize(path) ⇒ MigrationDetails
Returns a new instance of MigrationDetails.
4 5 6 |
# File 'lib/good_migrations/migration_details.rb', line 4 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/good_migrations/migration_details.rb', line 3 def path @path end |
Class Method Details
.currently_executing ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/good_migrations/migration_details.rb', line 8 def self.currently_executing migrate_dir_path = Rails.root.join("db/migrate/").to_s if (loc = caller.detect { |loc| loc.start_with?(migrate_dir_path) }) line_number_index = loc.index(":", migrate_dir_path.size) new(loc[0...line_number_index]) end end |
Instance Method Details
#associated_time ⇒ Object
17 18 19 20 21 |
# File 'lib/good_migrations/migration_details.rb', line 17 def associated_time = File.basename(@path).partition("_").first return if .size != 14 Time.parse() end |
#considered_before?(time) ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/good_migrations/migration_details.rb', line 23 def considered_before?(time) return false if time.nil? my_time = associated_time return false if my_time.nil? my_time < time end |