Class: Handcuffs::PhaseFilter
- Inherits:
-
Object
- Object
- Handcuffs::PhaseFilter
- Defined in:
- lib/handcuffs/phase_filter.rb
Instance Attribute Summary collapse
-
#attempted_phase ⇒ Object
readonly
Returns the value of attribute attempted_phase.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
Instance Method Summary collapse
- #filter(migration_proxies) ⇒ Object
-
#initialize(attempted_phase, direction) ⇒ PhaseFilter
constructor
A new instance of PhaseFilter.
- #proxies_with_migrations(migration_proxies) ⇒ Object
Constructor Details
#initialize(attempted_phase, direction) ⇒ PhaseFilter
Returns a new instance of PhaseFilter.
5 6 7 8 |
# File 'lib/handcuffs/phase_filter.rb', line 5 def initialize(attempted_phase, direction) @attempted_phase = attempted_phase @direction = direction end |
Instance Attribute Details
#attempted_phase ⇒ Object (readonly)
Returns the value of attribute attempted_phase.
2 3 4 |
# File 'lib/handcuffs/phase_filter.rb', line 2 def attempted_phase @attempted_phase end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
3 4 5 |
# File 'lib/handcuffs/phase_filter.rb', line 3 def direction @direction end |
Instance Method Details
#filter(migration_proxies) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/handcuffs/phase_filter.rb', line 10 def filter(migration_proxies) migration_hashes = proxies_with_migrations(migration_proxies) check_for_undefined_phases!(migration_hashes) check_for_undeclared_phases!(migration_hashes) by_phase = migration_hashes.lazy.group_by { |mh| phase(mh[:migration]) } defined_phases = Handcuffs.config.phases if(attempted_phase == :all) all_phases_by_configuration_order(by_phase, defined_phases) else runnable_for_phase(by_phase, defined_phases) end end |
#proxies_with_migrations(migration_proxies) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/handcuffs/phase_filter.rb', line 23 def proxies_with_migrations(migration_proxies) migration_proxies.map do |proxy| require(proxy.filename) { proxy: proxy, migration: Kernel.const_get("::#{proxy.name}") } end end |