Module: SlotMachine

Defined in:
lib/slot_machine.rb,
lib/slot_machine/helper.rb,
lib/slot_machine/version.rb

Overview

Main module for Slot Machine

Defined Under Namespace

Classes: Builder, Service

Constant Summary collapse

VERSION =
'0.3.1'.freeze

Class Method Summary collapse

Class Method Details

.helper_module(path: nil) ⇒ Object

create the module to be called as a helper Typically : “‘

helper SlotMachine.helper_module(my_path)

““



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/slot_machine/helper.rb', line 14

def self.helper_module(path: nil)
  # Read slot on the custom path
  slots = SlotMachine::Service.instance.read_slots(path)

  # Instantiate the new module
  @helper_module = Module.new

  # Add 1 method per partial in the module as well
  slots.each do |method_name, partial|
    @helper_module.module_eval do
      define_method(method_name) do |locals = {}, &block|
        SlotMachine::Service.instance.render_slot(self, partial, locals, &block)
      end
    end
  end

  @helper_module
end