Module: ActiveRecord::Acts::ShellscriptExecutable::ClassMethods

Defined in:
lib/acts_as_shellscript_executable/active_record/acts/shellscript_executable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_shellscript_executable(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/acts_as_shellscript_executable/active_record/acts/shellscript_executable.rb', line 11

def acts_as_shellscript_executable(options = {})
  configuration = { method: :execute!, script: :script }
  configuration.update(options) if options.is_a?(Hash)

  class_eval "    def \#{configuration[:method]}(&block)\n      script = @@__configuration__[:script]\n      answer = ''\n      if @@__configuration__[:parallel]\n        Thread.new do\n          __execute__(script, answer, block)\n        end\n        block_given? ? nil : answer\n      else\n        __execute__(script, answer, block)\n        block_given? ? nil : answer\n      end\n    end\n  EOV\n\n  class_variable_set(:@@__configuration__, configuration)\n  include ::ActiveRecord::Acts::ShellscriptExecutable::InstanceMethods\nend\n"