Module: ActiveAcl::Acts::AccessObject::ClassMethods
- Defined in:
- lib/active_acl/acts_as_access_object.rb
Instance Method Summary collapse
-
#acts_as_access_object(options = {}) ⇒ Object
Extend self with access object capabilites.
Instance Method Details
#acts_as_access_object(options = {}) ⇒ Object
Extend self with access object capabilites. See README for details on usage. Accepts the following options as a hash:
- grouped_by
-
name of the association acting as a group for access privilege
- group_class_name
-
class name of group class
- join_table
-
name of the join table
- foreign_key
-
foreign key of self in the join table
- association_foreign_key
-
foreign_key of the group class
- habtm
-
set to
true
if the grup is joined with a habtm association.
If not specified, the plugin tries to guess if the association is has_and_belongs_to_many or belongs_to by creating the singular form of the :grouped_by option and comparing it to itself: If it matches, it assumes a belongs_to association.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/active_acl/acts_as_access_object.rb', line 24 def acts_as_access_object( = {}) handler=ObjectHandler.new(self,) ActiveAcl::ACCESS_CLASSES[self.name] = handler has_many :requester_links, :as => :requester, :dependent => :delete_all, :class_name => 'ActiveAcl::RequesterLink' has_many :requester_acls, :through => :requester_links, :source => :acl, :class_name => 'ActiveAcl::Acl' has_many :target_links, :as => :target, :dependent => :delete_all, :class_name => 'ActiveAcl::TargetLink' has_many :target_acls, :through => :target_links, :source => :acl, :class_name => 'ActiveAcl::Acl' include InstanceMethods extend SingletonMethods include ActiveAcl::Acts::Grant ActiveAcl::Acl.instance_eval do has_many_polymorphs :requesters, {:from => ActiveAcl.from_classes, :through => :"active_acl/requester_links", :rename_individual_collections => true} has_many_polymorphs :targets, {:from => ActiveAcl.from_classes, :through => :"active_acl/target_links", :rename_individual_collections => true} end self.module_eval do # checks if method is defined to not break tests unless instance_methods.include? "reload_before_gacl" alias :reload_before_gacl :reload # Redefines reload, making shure privilege caches are cleared on reload def reload #:nodoc: reload_before_gacl end end end end |