Class: Godmin::Authorization::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/godmin/authorization/policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, record, default: false) ⇒ Policy

Returns a new instance of Policy.



6
7
8
9
10
# File 'lib/godmin/authorization/policy.rb', line 6

def initialize(user, record, default: false)
  @user = user
  @record = record
  @default = default
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



4
5
6
# File 'lib/godmin/authorization/policy.rb', line 4

def record
  @record
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/godmin/authorization/policy.rb', line 4

def user
  @user
end

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/godmin/authorization/policy.rb', line 28

def create?
  @default
end

#destroy?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/godmin/authorization/policy.rb', line 36

def destroy?
  @default
end

#edit?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/godmin/authorization/policy.rb', line 24

def edit?
  update?
end

#index?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/godmin/authorization/policy.rb', line 12

def index?
  @default
end

#new?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/godmin/authorization/policy.rb', line 20

def new?
  create?
end

#show?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/godmin/authorization/policy.rb', line 16

def show?
  @default
end

#update?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/godmin/authorization/policy.rb', line 32

def update?
  @default
end