Sha256: 35b187c578bb4e81d23b88c37afece2ef928b0a99395a46774c836e6f63aabfa

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

module Arrthorizer
  module Rails
    class ControllerConfiguration
      Error = Class.new(Arrthorizer::ArrthorizerException)

      def initialize(&block)
        yield self
      rescue LocalJumpError
        raise Error, "No builder block provided to ContextBuilder.new"
      end

      def defaults(&block)
        self.defaults_block = block
      end

      def for_action(action, &block)
        add_action_block(action, &block)
      end

      def block_for(action)
        action_blocks.fetch(action) { defaults_block }
      end

    private
      attr_accessor :defaults_block

      def add_action_block(action, &block)
        action_blocks[action] = block
      end

      def action_blocks
        @action_blocks ||= HashWithIndifferentAccess.new
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arrthorizer-0.1.0.pre2 lib/arrthorizer/rails/controller_configuration.rb
arrthorizer-0.1.0.pre lib/arrthorizer/rails/controller_configuration.rb