Module: PunditSelectors
- Included in:
- PunditOverwrite
- Defined in:
- lib/pundit_roles/pundit_selectors.rb
Overview
Module containing selectors for various authorized attributes, can be accessed as, ex: permitted_show_attributes
Instance Method Summary collapse
-
#association_create_associations ⇒ Object
returns the permitted create associations of the associated models.
-
#association_create_attributes ⇒ Object
returns the permitted create attributes of the associated models.
-
#association_permissions ⇒ Object
returns the permission hashes of permitted associations, ex: => {:attributes => {:show => [:text], :associations => => [:comments]}}.
-
#association_show_associations ⇒ Object
returns the permitted show associations of the associated models.
-
#association_show_attributes ⇒ Object
returns the permitted show attributes of the associated models.
-
#association_update_associations ⇒ Object
returns the permitted update associations of the associated models.
-
#association_update_attributes ⇒ Object
returns the permitted update attributes of the associated models.
-
#attribute_permissions ⇒ Object
returns the formatted attributes for :show, :create and :update, ready to plug-and-play.
-
#permissions ⇒ Object
returns the permission hash for the primary model.
-
#permitted_associations ⇒ Object
returns the permitted associations in the form of [Array] -> [=> {:comments => [:author]}, :settings].
- #permitted_create_associations ⇒ Object
- #permitted_create_attributes ⇒ Object
- #permitted_show_associations ⇒ Object
- #permitted_show_attributes ⇒ Object
- #permitted_update_associations ⇒ Object
- #permitted_update_attributes ⇒ Object
-
#primary_create_associations ⇒ Object
returns the permitted create associations of the primary model.
-
#primary_create_attributes ⇒ Object
returns the permitted create attributes of the primary model.
-
#primary_show_associations ⇒ Object
returns the permitted show associations of the primary model.
-
#primary_show_attributes ⇒ Object
returns the permitted show attributes of the primary model.
-
#primary_update_associations ⇒ Object
returns the permitted update associations of the primary model.
-
#primary_update_attributes ⇒ Object
returns the permitted update attributes of the primary model.
Instance Method Details
#association_create_associations ⇒ Object
returns the permitted create associations of the associated models
119 120 121 122 123 124 125 126 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 119 def association_create_associations return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:associations].slice(:create)[:create] end return associated_stuff end |
#association_create_attributes ⇒ Object
returns the permitted create attributes of the associated models
89 90 91 92 93 94 95 96 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 89 def association_create_attributes return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:attributes].slice(:create)[:create] end return associated_stuff end |
#association_permissions ⇒ Object
returns the permission hashes of permitted associations, ex: => {:attributes => {:show => [:text], :associations => => [:comments]}}
20 21 22 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 20 def @pundit_permission_table end |
#association_show_associations ⇒ Object
returns the permitted show associations of the associated models
109 110 111 112 113 114 115 116 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 109 def association_show_associations return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:associations].slice(:show)[:show] end return associated_stuff end |
#association_show_attributes ⇒ Object
returns the permitted show attributes of the associated models
79 80 81 82 83 84 85 86 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 79 def association_show_attributes return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:attributes].slice(:show)[:show] end return associated_stuff end |
#association_update_associations ⇒ Object
returns the permitted update associations of the associated models
129 130 131 132 133 134 135 136 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 129 def association_update_associations return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:associations].slice(:update)[:update] end return associated_stuff end |
#association_update_attributes ⇒ Object
returns the permitted update attributes of the associated models
99 100 101 102 103 104 105 106 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 99 def association_update_attributes return {} unless @pundit_permission_table associated_stuff = {} @pundit_permission_table.each do |role, action| associated_stuff[role] = action[:attributes].slice(:update)[:update] end return associated_stuff end |
#attribute_permissions ⇒ Object
returns the formatted attributes for :show, :create and :update, ready to plug-and-play
10 11 12 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 10 def @pundit_attribute_lists end |
#permissions ⇒ Object
returns the permission hash for the primary model
5 6 7 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 5 def @pundit_primary_permissions end |
#permitted_associations ⇒ Object
returns the permitted associations in the form of [Array] -> [=> {:comments => [:author]}, :settings]
15 16 17 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 15 def permitted_associations @pundit_permitted_associations end |
#permitted_create_associations ⇒ Object
40 41 42 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 40 def permitted_create_associations @pundit_permitted_associations[:create] end |
#permitted_create_attributes ⇒ Object
28 29 30 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 28 def permitted_create_attributes @pundit_attribute_lists[:create] end |
#permitted_show_associations ⇒ Object
36 37 38 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 36 def permitted_show_associations @pundit_permitted_associations[:show] end |
#permitted_show_attributes ⇒ Object
24 25 26 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 24 def permitted_show_attributes @pundit_attribute_lists[:show] end |
#permitted_update_associations ⇒ Object
44 45 46 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 44 def permitted_update_associations @pundit_permitted_associations[:update] end |
#permitted_update_attributes ⇒ Object
32 33 34 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 32 def permitted_update_attributes @pundit_attribute_lists[:update] end |
#primary_create_associations ⇒ Object
returns the permitted create associations of the primary model
69 70 71 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 69 def primary_create_associations @pundit_primary_permissions[:associations][:create] end |
#primary_create_attributes ⇒ Object
returns the permitted create attributes of the primary model
54 55 56 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 54 def primary_create_attributes @pundit_primary_permissions[:attributes][:create] end |
#primary_show_associations ⇒ Object
returns the permitted show associations of the primary model
64 65 66 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 64 def primary_show_associations @pundit_primary_permissions[:associations][:show] end |
#primary_show_attributes ⇒ Object
returns the permitted show attributes of the primary model
49 50 51 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 49 def primary_show_attributes @pundit_primary_permissions[:attributes][:show] end |
#primary_update_associations ⇒ Object
returns the permitted update associations of the primary model
74 75 76 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 74 def primary_update_associations @pundit_primary_permissions[:associations][:update] end |
#primary_update_attributes ⇒ Object
returns the permitted update attributes of the primary model
59 60 61 |
# File 'lib/pundit_roles/pundit_selectors.rb', line 59 def primary_update_attributes @pundit_primary_permissions[:attributes][:update] end |