Module: MigrationHistory::QueryMethods::ClassMethods
- Defined in:
- lib/migration_history/query.rb
Instance Attribute Summary collapse
-
#migration_file_dir ⇒ Object
Returns the value of attribute migration_file_dir.
Instance Method Summary collapse
- #all ⇒ Object
- #filter(table_name, column_name = nil, action_name = nil) ⇒ Object
- #reload! ⇒ Object
- #tracker ⇒ Object
Instance Attribute Details
#migration_file_dir ⇒ Object
Returns the value of attribute migration_file_dir.
10 11 12 |
# File 'lib/migration_history/query.rb', line 10 def migration_file_dir @migration_file_dir end |
Instance Method Details
#all ⇒ Object
33 34 35 |
# File 'lib/migration_history/query.rb', line 33 def all ResultSet.new(tracker.migration_info) end |
#filter(table_name, column_name = nil, action_name = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/migration_history/query.rb', line 12 def filter(table_name, column_name = nil, action_name = nil) table_name = table_name.to_sym column_name = column_name.to_sym if column_name action_name = action_name.to_sym if action_name raise InvalidError.new("Table name is required") unless table_name found_migration_info = {} tracker.migration_info.values.each do |v| if v[:actions].to_a.any? { |action| action.dig(:details, :table_name) == table_name && (column_name.nil? || action.dig(:details, :column_name) == column_name) && (action_name.nil? || action[:action] == action_name) } found_migration_info[v[:class_name]] = v end end ResultSet.new(found_migration_info) end |
#reload! ⇒ Object
41 42 43 44 |
# File 'lib/migration_history/query.rb', line 41 def reload! @tracker = nil tracker end |