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?, #index?, #initialize, #new?, #scope, #show?, #update?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
# File 'app/policies/proclaim/subscription_policy.rb', line 3

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)


17
18
19
# File 'app/policies/proclaim/subscription_policy.rb', line 17

def destroy?
  true # Anyone can unsubscribe (it requires a token anyway)
end

#unsubscribe?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/policies/proclaim/subscription_policy.rb', line 13

def unsubscribe?
  destroy?
end