Class: Pageflow::EntryPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/pageflow/entry_policy.rb

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, entry) ⇒ EntryPolicy

Returns a new instance of EntryPolicy.



39
40
41
42
43
# File 'app/policies/pageflow/entry_policy.rb', line 39

def initialize(user, entry)
  @user = user
  @entry = entry
  @query = EntryRoleQuery.new(user, entry)
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



37
38
39
# File 'app/policies/pageflow/entry_policy.rb', line 37

def query
  @query
end

#userObject (readonly)

Returns the value of attribute user.



37
38
39
# File 'app/policies/pageflow/entry_policy.rb', line 37

def user
  @user
end

Instance Method Details

#add_member_to?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'app/policies/pageflow/entry_policy.rb', line 110

def add_member_to?
  manage?
end

#confirm_encoding?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'app/policies/pageflow/entry_policy.rb', line 69

def confirm_encoding?
  edit?
end

#create?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'app/policies/pageflow/entry_policy.rb', line 97

def create?
  query.(:publisher)
end

#create_any?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'app/policies/pageflow/entry_policy.rb', line 93

def create_any?
  AccountPolicy::Scope.new(@user, Account).entry_creatable.any?
end

#destroy?Boolean

Returns:

  • (Boolean)


146
147
148
# File 'app/policies/pageflow/entry_policy.rb', line 146

def destroy?
  
end

#destroy_membership_on?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'app/policies/pageflow/entry_policy.rb', line 118

def destroy_membership_on?
  manage?
end

#duplicate?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'app/policies/pageflow/entry_policy.rb', line 101

def duplicate?
  publish?
end

#edit?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/policies/pageflow/entry_policy.rb', line 65

def edit?
  query.has_at_least_role?(:editor)
end

#edit_outline?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'app/policies/pageflow/entry_policy.rb', line 73

def edit_outline?
  edit?
end

#edit_role_on?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'app/policies/pageflow/entry_policy.rb', line 114

def edit_role_on?
  manage?
end

#filter_by_type?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/policies/pageflow/entry_policy.rb', line 49

def filter_by_type?
  user.admin?
end

#index_widgets_for?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'app/policies/pageflow/entry_policy.rb', line 77

def index_widgets_for?
  edit?
end

#manage?Boolean

Returns:

  • (Boolean)


105
106
107
108
# File 'app/policies/pageflow/entry_policy.rb', line 105

def manage?
  user.admin? ||
    query.has_at_least_role?(:manager)
end

#manage_account_of?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'app/policies/pageflow/entry_policy.rb', line 136

def 
  query.(:manager)
end

#preview?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/policies/pageflow/entry_policy.rb', line 53

def preview?
  query.has_at_least_role?(:previewer)
end

#publish?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'app/policies/pageflow/entry_policy.rb', line 89

def publish?
  query.has_at_least_role?(:publisher)
end

#publish_on_account_of?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'app/policies/pageflow/entry_policy.rb', line 122

def 
  query.(:publisher)
end

#read?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/policies/pageflow/entry_policy.rb', line 57

def read?
  preview?
end

#recordObject



45
46
47
# File 'app/policies/pageflow/entry_policy.rb', line 45

def record
  @entry
end

#restore?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'app/policies/pageflow/entry_policy.rb', line 81

def restore?
  edit?
end

#snapshot?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'app/policies/pageflow/entry_policy.rb', line 85

def snapshot?
  edit?
end

#update_account_on?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'app/policies/pageflow/entry_policy.rb', line 126

def 
  
end

#update_feature_configuration_on?Boolean

Returns:

  • (Boolean)


140
141
142
143
144
# File 'app/policies/pageflow/entry_policy.rb', line 140

def update_feature_configuration_on?
  user.admin? ||
    (!permissions_config.only_admins_may_update_features &&
     )
end

#update_site_on?Boolean

Returns:

  • (Boolean)


130
131
132
133
134
# File 'app/policies/pageflow/entry_policy.rb', line 130

def update_site_on?
  user.admin? ||
    (!permissions_config.only_admins_may_update_site &&
     )
end

#use_files?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/policies/pageflow/entry_policy.rb', line 61

def use_files?
  preview?
end