Sha256: 27a8c7a7ea8f9f83bec328647e5aa878596f75034faeb498864e8ddf9de3a82a

Contents?: true

Size: 357 Bytes

Versions: 9

Compression:

Stored size: 357 Bytes

Contents

require 'allowance'

module Happy
  class Controller
    module Permissions
      def permissions(&blk)
        (@env['happy.permissions'] ||= Allowance::Permissions.new).tap do |p|
          if blk
            blk.arity == 0 ? p.instance_exec(&blk) : blk.call(p)
          end
        end
      end

      alias_method :can, :permissions
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
happy-0.1.0 lib/happy/controller/permissions.rb
happy-0.1.0.pre28 lib/happy/controller/permissions.rb
happy-0.1.0.pre27 lib/happy/controller/permissions.rb
happy-0.1.0.pre25 lib/happy/controller/permissions.rb
happy-0.1.0.pre24 lib/happy/controller/permissions.rb
happy-0.1.0.pre23 lib/happy/controller/permissions.rb
happy-0.1.0.pre22 lib/happy/controller/permissions.rb
happy-0.1.0.pre21 lib/happy/controller/permissions.rb
happy-0.1.0.pre20 lib/happy/controller/permissions.rb