Sha256: 95d1da98824c667e79d7435940ecd72d51fa22d9f6c70496ba6e7e6d291877be

Contents?: true

Size: 441 Bytes

Versions: 4

Compression:

Stored size: 441 Bytes

Contents

module IAmICan
  module Permission
    class PArray < ::Array
      attr_accessor :pms

      def matched?(pms_name)
        return false if self.blank?
        self.pms = pms_name.to_sym
        found? || covered?
      end

      def found?
        pms.in? self
      end

      def covered?
        pred, obj_type, obj_id = pms.to_s.split('_')
        pred.to_sym.in?(self) || :"#{pred}_#{obj_type}".in?(self)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i_am_i_can-3.0.1 lib/i_am_i_can/permission/p_array.rb
i_am_i_can-3.0.0 lib/i_am_i_can/permission/p_array.rb
i_am_i_can-3.0.0pre lib/i_am_i_can/permission/p_array.rb
i_am_i_can-2.1.0 lib/i_am_i_can/permission/p_array.rb