module PunditSelectors

Module containing selectors for various authorized attributes, can be accessed as, ex: permitted_show_attributes

Public Instance Methods

association_create_associations() click to toggle source

returns the permitted create associations of the associated models

# 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() click to toggle source

returns the permitted create attributes of the associated models

# 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() click to toggle source

returns the permission hashes of permitted associations, ex: {:posts => {:attributes => {:show => [:text]}, :associations => {:show => [:comments]}}}

# File lib/pundit_roles/pundit_selectors.rb, line 20
def association_permissions
  @pundit_permission_table
end
association_show_associations() click to toggle source

returns the permitted show associations of the associated models

# 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() click to toggle source

returns the permitted show attributes of the associated models

# 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() click to toggle source

returns the permitted update associations of the associated models

# 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() click to toggle source

returns the permitted update attributes of the associated models

# 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() click to toggle source

returns the formatted attributes for :show, :create and :update, ready to plug-and-play

# File lib/pundit_roles/pundit_selectors.rb, line 10
def attribute_permissions
  @pundit_attribute_lists
end
permissions() click to toggle source

returns the permission hash for the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 5
def permissions
  @pundit_primary_permissions
end
permitted_associations() click to toggle source

returns the permitted associations in the form of [Array] -> [{:posts => {:comments => [:author]}}, :settings]

# File lib/pundit_roles/pundit_selectors.rb, line 15
def permitted_associations
  @pundit_permitted_associations
end
permitted_create_associations() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 40
def permitted_create_associations
  @pundit_permitted_associations[:create]
end
permitted_create_attributes() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 28
def permitted_create_attributes
  @pundit_attribute_lists[:create]
end
permitted_show_associations() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 36
def permitted_show_associations
  @pundit_permitted_associations[:show]
end
permitted_show_attributes() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 24
def permitted_show_attributes
  @pundit_attribute_lists[:show]
end
permitted_update_associations() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 44
def permitted_update_associations
  @pundit_permitted_associations[:update]
end
permitted_update_attributes() click to toggle source
# File lib/pundit_roles/pundit_selectors.rb, line 32
def permitted_update_attributes
  @pundit_attribute_lists[:update]
end
primary_create_associations() click to toggle source

returns the permitted create associations of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 69
def primary_create_associations
  @pundit_primary_permissions[:associations][:create]
end
primary_create_attributes() click to toggle source

returns the permitted create attributes of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 54
def primary_create_attributes
  @pundit_primary_permissions[:attributes][:create]
end
primary_show_associations() click to toggle source

returns the permitted show associations of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 64
def primary_show_associations
  @pundit_primary_permissions[:associations][:show]
end
primary_show_attributes() click to toggle source

returns the permitted show attributes of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 49
def primary_show_attributes
  @pundit_primary_permissions[:attributes][:show]
end
primary_update_associations() click to toggle source

returns the permitted update associations of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 74
def primary_update_associations
  @pundit_primary_permissions[:associations][:update]
end
primary_update_attributes() click to toggle source

returns the permitted update attributes of the primary model

# File lib/pundit_roles/pundit_selectors.rb, line 59
def primary_update_attributes
  @pundit_primary_permissions[:attributes][:update]
end