Class: MoveToGo::CanBecomeImmutable
- Inherits:
-
Object
- Object
- MoveToGo::CanBecomeImmutable
show all
- Defined in:
- lib/move-to-go/can_become_immutable.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.immutable_accessor(name) ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/move-to-go/can_become_immutable.rb', line 4
def self.immutable_accessor(name)
define_method(name) do
return instance_variable_get("@#{name}")
end
define_method("#{name}=") do |value|
raise_if_immutable
instance_variable_set("@#{name}", value)
end
end
|
Instance Method Details
#is_immutable ⇒ Object
25
26
27
|
# File 'lib/move-to-go/can_become_immutable.rb', line 25
def is_immutable()
@is_immutable
end
|
#raise_if_immutable ⇒ Object
15
16
17
18
19
|
# File 'lib/move-to-go/can_become_immutable.rb', line 15
def raise_if_immutable
if @is_immutable
raise ObjectIsImmutableError
end
end
|
#set_is_immutable ⇒ Object
21
22
23
|
# File 'lib/move-to-go/can_become_immutable.rb', line 21
def set_is_immutable()
@is_immutable = true
end
|