Class: MethodCallbacks::Locker

Inherits:
Object
  • Object
show all
Defined in:
lib/method_callbacks/locker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocker

Returns a new instance of Locker.



5
6
7
# File 'lib/method_callbacks/locker.rb', line 5

def initialize
  self.state = :unlocked
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/method_callbacks/locker.rb', line 3

def state
  @state
end

Instance Method Details

#lock!Object



9
10
11
# File 'lib/method_callbacks/locker.rb', line 9

def lock!
  self.state = :locked
end

#locked?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/method_callbacks/locker.rb', line 13

def locked?
  state == :locked
end

#unlock!Object



17
18
19
# File 'lib/method_callbacks/locker.rb', line 17

def unlock!
  self.state = :unlocked
end