Class: RailsAsyncMigrations::Migration::Lock

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_async_migrations/migration/lock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, method_name) ⇒ Lock

Returns a new instance of Lock.



9
10
11
12
# File 'lib/rails_async_migrations/migration/lock.rb', line 9

def initialize(resource_class, method_name)
  @resource_class = resource_class
  @method_name = method_name
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



7
8
9
# File 'lib/rails_async_migrations/migration/lock.rb', line 7

def method_name
  @method_name
end

#resource_classObject (readonly)

Returns the value of attribute resource_class.



7
8
9
# File 'lib/rails_async_migrations/migration/lock.rb', line 7

def resource_class
  @resource_class
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/rails_async_migrations/migration/lock.rb', line 14

def perform
  return false unless locked_method?
  return false if unlocked?

  preserve_method_logics

  suspend_lock do
    overwrite_method
  end
end

#suspend_lock(&block) ⇒ Object



25
26
27
28
29
# File 'lib/rails_async_migrations/migration/lock.rb', line 25

def suspend_lock(&block)
  unlock
  yield if block_given?
  lock
end