Class: Accessly::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/accessly/base.rb

Direct Known Subclasses

Permission::Grant, Permission::Revoke, Query

Instance Method Summary collapse

Constructor Details

#initialize(actors) ⇒ Base

Create an instance of Accessly::Base. Lookups are cached in inherited object(s) to prevent redundant calls to the database. Pass in a Hash or ActiveRecord::Base for actors if the actor(s) inherit some permissions from other actors in the system. This may happen when you have a user in one or more groups or organizations with their own access control permissions.

Parameters:

  • actors (Hash, ActiveRecord::Base)

    The actor(s) we’re checking permission(s)



16
17
18
19
20
21
22
23
24
# File 'lib/accessly/base.rb', line 16

def initialize(actors)
  @segment_id = -1
  @actors = case actors
  when Hash
    actors
  else
    { actors.class.name => actors.id }
  end
end

Instance Method Details

#on_segment(segment_id) ⇒ Accessly::Base

Returns the object caller

Parameters:

  • segment_id (Integer)

    The segment to further separate permissions requests

Returns:



28
29
30
31
# File 'lib/accessly/base.rb', line 28

def on_segment(segment_id)
  @segment_id = segment_id
  self
end