Sha256: 9fc1c1bc92b2e43d780fe36f7c210f67af60c5212ea28f1fb3fb803652a2dda0
Contents?: true
Size: 909 Bytes
Versions: 46
Compression:
Stored size: 909 Bytes
Contents
module Avo module Concerns module HasResourceStimulusControllers extend ActiveSupport::Concern included do class_attribute :stimulus_controllers, default: "" end def get_stimulus_controllers return "" if view.nil? controllers = [] case view.to_sym when :show controllers << "resource-show" when :new, :edit controllers << "resource-edit" when :index controllers << "resource-index" end controllers << self.class.stimulus_controllers controllers.join " " end def stimulus_data_attributes attributes = { controller: get_stimulus_controllers, } get_stimulus_controllers.split(" ").each do |controller| attributes["#{controller}-view-value"] = view end attributes end end end end
Version data entries
46 entries across 46 versions & 1 rubygems