Sha256: d011dbbd2ffa03df33b7c8e73e1c2625d5396f0c6b51acf4bac87167e49537c9

Contents?: true

Size: 831 Bytes

Versions: 11

Compression:

Stored size: 831 Bytes

Contents

require 'allowance'

module Happy
  module Extensions
    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
end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
happy-0.1.0.pre12 lib/happy/ext/permissions.rb
happy-0.1.0.pre11 lib/happy/ext/permissions.rb
happy-0.1.0.pre10 lib/happy/ext/permissions.rb
happy-0.1.0.pre9 lib/happy/ext/permissions.rb
happy-0.1.0.pre8 lib/happy/ext/permissions.rb
happy-0.1.0.pre7 lib/happy/ext/permissions.rb
happy-0.1.0.pre.6 lib/happy/ext/permissions.rb
happy-0.1.0.pre.5 lib/happy/ext/permissions.rb
happy-0.1.0.pre.4 lib/happy/ext/permissions.rb
happy-0.1.0.pre.3 lib/happy/ext/permissions.rb
happy-0.1.0.pre.2 lib/happy/ext/permissions.rb