9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/acts_as_shellscript_executable/active_record/acts/shellscript_executable.rb', line 9
def acts_as_shellscript_executable(options = {})
configuration = { method: :execute!, script: :script }
configuration.update(options) if options.is_a?(Hash)
method = configuration[:method]
class_eval <<-EOV
def #{method}(&block)
script = @@__configurations__[:#{method}][:script]
answer = ''
__execute__(script, answer, block)
block_given? ? nil : answer
end
EOV
configurations = begin
class_variable_get(:@@__configurations__)
rescue NameError
{}
end
configurations[method] = configuration
class_variable_set(:@@__configurations__, configurations)
include ::ActiveRecord::Acts::ShellscriptExecutable::InstanceMethods
end
|