Sha256: dd5f9a319367f187758d63211739bee3e92ba2fdc231382dc305e140ba409950

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

module Stimul8
  module Component
    module Actions
      extend ActiveSupport::Concern

      def action action_name, parameters = {}
        action = if (event = parameters.delete(:event))
          "#{event}->stimul8#callAction"
        elsif (events = parameters.delete(:events))
          Array.wrap(events).map { |e| "#{e}->stimul8#callAction" }.join(" ")
        else
          "stimul8#callAction"
        end
        data = {action: action, stimul8_action_param: action_name.to_s}
        parameters.each do |name, value|
          data[:"stimul8_#{name.to_s.underscore}_param"] = value
        end
        {data: data}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stimul8-0.1.0 lib/stimul8/component/actions.rb