Sha256: bd9d48b70a5fa50a3943f9013807e1eee858cf78cf5bb8803bbc8b9e7fe75db2

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

class ParentResource < ActiveRecord::Base
  has_many :child_resources
  attr_accessible :description, :name

  include Alberich::PermissionedObject

  # for objects with a user or owner attribute, owner-level privileges
  # can automatically be conferred with the following
  #   after_create "assign_owner_roles(owner)"
  # otherwise this will need to be handled explicitly in the
  # controller create action

  # We don't need to override perm_ancestors since this type doesn't
  # inherit from anything

  # We don't need to override derived_subtree since nothing inherits
  # from this type
  def derived_subtree(role = nil)
    subtree = super(role)
    if (role.nil? || role.privilege_target_match(ChildResource))
      subtree += child_resources
    end
    subtree
  end

  # Other resource types for which we need to allow privileges at this
  # level (often objects which sub-resources this type)
  def self.additional_privilege_target_types
    [ChildResource]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alberich-0.2.0 test/dummy/app/models/parent_resource.rb