Module: Agrippa::Immutable::ClassMethods
Instance Method Summary
collapse
#state_accessor, #state_reader, #state_writer
Instance Method Details
#__define_state_reader(key, original_caller, options) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/agrippa/immutable.rb', line 22
def __define_state_reader(key, original_caller, options)
name = ::Agrippa::Methods.name(key, options)
file, line = original_caller.first.split(':', 2)
line = line.to_i
spec = "def #{name}; fetch(:#{key}); end"
module_eval(spec, file, line)
self
end
|
#__define_state_writer(key, original_caller, options) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/agrippa/immutable.rb', line 31
def __define_state_writer(key, original_caller, options)
name = ::Agrippa::Methods.name(key, options)
name = ::Agrippa::Methods.name(name, prefix: "set") \
unless (options[:prefix] == false)
file, line = original_caller.first.split(':', 2)
line = line.to_i
spec = "def #{name}(v); store(:#{key}, v); end"
module_eval(spec, file, line)
mark_as_command(name)
self
end
|