ref: master
app/controllers/concerns/custom_design.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
module CustomDesign extend ActiveSupport::Concern included do extend ClassMethods include InstanceMethods before_filter :load_custom_design if self.respond_to? :before_filter end module ClassMethods def no_design_blocks @no_design_blocks = true end def use_custom_design options = {} @custom_design = options end def custom_design @custom_design ||= {} end def uses_design_blocks? !@no_design_blocks end end module InstanceMethods protected def uses_design_blocks? !@no_design_blocks && self.class.uses_design_blocks? end def load_custom_design # see also: LayoutHelper#body_classes @layout_template = self.class.custom_design[:layout_template] end def custom_design @custom_design || self.class.custom_design end end end |