Sha256: d5b2b34ffaf608119aa026042080b77a2e03bdd7025e30dc539e9ace2861b0b3

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

module CanTango
  module Permit
    class User < Base
      attr_accessor :key, :match_value

      # creates the permit
      # @param [Permits::Ability] the ability
      # @param [Hash] the options
      def initialize ability
        super
      end

      def self.hash_key
        nil
      end

      def valid?
        debug_invalid if !match?
        true
      end

      protected

      def match?
        return false if !subject.respond_to? key
        subject.send(key) == match_value
      end

      def debug_invalid
        debug "Not a valid permit for subject: #{key} != #{match_value}"
      end
    end
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-permits-0.1.1 lib/cantango/permit/user.rb