Method: Longleaf::FileHelpers.create_work_class

Defined in:
lib/longleaf/specs/file_helpers.rb

.create_work_class(lib_dir, class_name, file_name, module_name, is_applicable, init_body, perform) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/longleaf/specs/file_helpers.rb', line 43

def self.create_work_class(lib_dir, class_name, file_name, module_name, is_applicable, init_body, perform)
  class_contents = %Q(
    class #{class_name}
      def initialize(service_def, app_manager)
        #{init_body}
      end
      def perform(file_rec, event)
        #{perform}
      end
      def is_applicable?(event)
        #{is_applicable}
      end
    end
  )
  class_contents = "module #{module_name}\n#{class_contents}\nend" unless module_name.nil?
  create_test_file(dir: lib_dir, name: file_name, content: class_contents)
end