Sha256: c5b6d8b7ed846161c439740ee62eb1ae625f4ebfc50aeeed1ef2a7dd600ba063

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

module Happy
  module Permissions
    module ContextExtensions
      extend ActiveSupport::Concern

      def permissions(&blk)
        @permissions ||= Allowance.define
      end

      def can?(*args)
        permissions.allowed?(*args)
      end
    end

    module ControllerExtensions
      extend ActiveSupport::Concern

      included do
        delegate :can?, :to => :context
      end

      module ClassMethods
        attr_accessor :permissions_blk

        def permissions(&blk)
          self.permissions_blk = blk
        end
      end
    end
  end
end

Happy::Context.send(:include, Happy::Permissions::ContextExtensions)
Happy::Controller.send(:include, Happy::Permissions::ControllerExtensions)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
happy-0.1.0.pre.1 lib/happy/permissions.rb