9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# 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)
class_eval <<-EOV
def #{configuration[:method]}(&block)
script = @@__configuration__[:script]
answer = ''
__execute__(script, answer, block)
block_given? ? nil : answer
end
EOV
class_variable_set(:@@__configuration__, configuration)
include ::ActiveRecord::Acts::ShellscriptExecutable::InstanceMethods
end
|