Sha256: a37f5e408372b7db0dae8128c9e3285cf0a36be17dca10c0312fd51d8f26891e

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 Bytes

Contents

module SimpleHelpers
  module ActionController
    def simple_helper(*name_or_array_of_names)
      main_options   = name_or_array_of_names.extract_options!
      array_of_names = SimpleHelpers::Support.certified_array!(name_or_array_of_names)

      SimpleHelpers::Support.log "Defining methods #{array_of_names.inspect} to #{self.class.inspect}"

      array_of_names.each do |name_symbol|
        name = name_symbol.underscore

        # define_methods
        SimpleHelpers::Support.create_method(self, name)

        # method helper
        ::ActionController::Base.helper_method name.to_s

        # initialize
        instance_variable_set "@#{name}_options", Hash[main_options] unless main_options.empty?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_helpers-1.0.0 lib/simple_helpers/action_controller.rb
simple_helpers-0.0.5 lib/simple_helpers/action_controller.rb