Sha256: a22df427f0eca81ad0aeaa94ac1caf038ed90685dd385b8d4b42a86b3c04a87e

Contents?: true

Size: 825 Bytes

Versions: 47

Compression:

Stored size: 825 Bytes

Contents

module Saucy
  class Layouts
    def initialize
      @controllers = {}
    end

    def method_missing(controller_name, *args, &block)
      @controllers[controller_name.to_s] ||= Controller.new
    end

    def self.to_proc
      lambda do |controller|
        controller_name = controller.controller_name
        action_name = controller.action_name
        Rails.application.config.saucy.layouts.send(controller_name).send(action_name)
      end
    end

    private

    class Controller
      def initialize
        @actions = {}
      end

      def method_missing(method_name, *args, &block)
        action_name = method_name.to_s
        if action_name.sub!(/=$/, '')
          @actions[action_name] = args.first
        else
          @actions[action_name] ||= "application"
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
saucy-0.1.7 lib/saucy/layouts.rb
saucy-0.1.6 lib/saucy/layouts.rb
saucy-0.1.5 lib/saucy/layouts.rb
saucy-0.1.4 lib/saucy/layouts.rb
saucy-0.1.3 lib/saucy/layouts.rb
saucy-0.1.2 lib/saucy/layouts.rb
saucy-0.1.1 lib/saucy/layouts.rb