Module: Agrippa::Mutable::ClassMethods
Instance Method Summary
collapse
#state_accessor, #state_reader, #state_writer
Instance Method Details
#__define_state_reader(key, original_caller, options) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/agrippa/mutable.rb', line 17
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}; @#{key}; end"
module_eval(spec, file, line)
self
end
|
#__define_state_writer(key, original_caller, options) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/agrippa/mutable.rb', line 26
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}(value); @#{key} = value; self; end"
module_eval(spec, file, line)
mark_as_command(name)
self
end
|