Sha256: 0dce3c0f2c736851f74ce9336375d05fecd0cf613ff1c733a3833ea1d90e212f
Contents?: true
Size: 1.33 KB
Versions: 7
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true module Scribo module ActionControllerHelpers extend ActiveSupport::Concern included do attr_accessor :scribo_value_purpose, :scribo_value_layout, :scribo_value_application_assets if respond_to? :helper_method helper_method :scribo_layout_identifier, :scribo_application_assets, :scribo_purpose end def scribo_layout_identifier scribo_value_for(scribo_value_layout) end def scribo_purpose scribo_value_for(scribo_value_purpose) end def scribo_application_assets scribo_value_for(scribo_value_application_assets) end private def scribo_value_for(value) return instance_eval(&value) if value.is_a? Proc return send(value) if value.is_a? Symbol value end end class_methods do def scribo(*args) options = args.extract_options! if options.present? prepend_before_action do |controller| controller.send(:scribo_value_layout=, options[:layout]) if options[:layout] controller.send(:scribo_value_purpose=, options[:purpose]) if options[:purpose] controller.send(:scribo_value_application_assets=, options[:assets]) end layout 'scribo' if options[:layout] end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems