Class: Proclaim::SubscriptionPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/proclaim/subscription_policy.rb

Defined Under Namespace

Classes: Scope

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#record, #user

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#edit?, #initialize, #new?, #scope, #update?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'app/policies/proclaim/subscription_policy.rb', line 11

def create?
  # A user can subscribe to anything. Guests can only subscribe to
  # published posts or the blog in general.
  if @user.nil? and @record.post
    @record.post.published?
  else
    true
  end
end

#destroy?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/policies/proclaim/subscription_policy.rb', line 21

def destroy?
  show?
end

#index?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/policies/proclaim/subscription_policy.rb', line 3

def index?
  not @user.nil? # A user can view the list of subscriptions
end

#show?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/policies/proclaim/subscription_policy.rb', line 7

def show?
  true # Anyone can show the subscription since it requires a token
end