Class: ExplicitActiveRecord::Persistence::PermissionStore

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/explicit_activerecord/persistence.rb

Overview

Note that this should probably be a ‘private_constant :PermissionStore` However, some clients are stubbing the methods here because the want to stub ExplicitActiveRecord in spec.

TODO: Give a supported API for stubbing explicit persistence and then make this a private constant.

Class Method Summary collapse

Class Method Details

.permit(model) ⇒ Object



109
110
111
# File 'lib/explicit_activerecord/persistence.rb', line 109

def self.permit(model)
  self.storage.push(model)
end

.permitted?(model) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/explicit_activerecord/persistence.rb', line 120

def self.permitted?(model)
  model.can_be_dangerously_updated || self.storage.include?(model)
end

.revoke(model) ⇒ Object



114
115
116
117
# File 'lib/explicit_activerecord/persistence.rb', line 114

def self.revoke(model)
  idx = self.storage.index(model)
  self.storage.delete_at(idx) unless idx.nil?
end

.storageObject



125
126
127
# File 'lib/explicit_activerecord/persistence.rb', line 125

def self.storage
  @storage ||= []
end