Class: Rolify::Adapter::Base

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

Direct Known Subclasses

ActiveRecord, Mongoid

Instance Method Summary collapse

Constructor Details

#initialize(role_cname) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/rolify/adapters/base.rb', line 4

def initialize(role_cname)
  @role_cname = role_cname
end

Instance Method Details

#add(relation, role_name, resource = nil) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/rolify/adapters/base.rb', line 24

def add(relation, role_name, resource = nil)
  raise NotImplementedError.new("You must implement add")
end

#build_conditions(relation, args) ⇒ Object

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/rolify/adapters/base.rb', line 44

def build_conditions(relation, args)
  raise NotImplementedError.new("You must implement build_conditions")
end

#build_query(role, resource = nil) ⇒ Object

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/rolify/adapters/base.rb', line 48

def build_query(role, resource = nil)
  raise NotImplementedError.new("You must implement build_query")
end

#exists?(relation, column) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/rolify/adapters/base.rb', line 40

def exists?(relation, column)
  raise NotImplementedError.new("You must implement exists?")
end

#find(relation, role_name, resource) ⇒ Object

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/rolify/adapters/base.rb', line 12

def find(relation, role_name, resource)
  raise NotImplementedError.new("You must implement find")
end

#find_or_create_by(role_name, resource_type = nil, resource_id = nil) ⇒ Object

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/rolify/adapters/base.rb', line 20

def find_or_create_by(role_name, resource_type = nil, resource_id = nil)
  raise NotImplementedError.new("You must implement find_or_create_by")
end

#in(resources, roles) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/rolify/adapters/base.rb', line 36

def in(resources, roles)
  raise NotImplementedError.new("You must implement in")
end

#remove(relation, role_name, resource = nil) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/rolify/adapters/base.rb', line 28

def remove(relation, role_name, resource = nil)
  raise NotImplementedError.new("You must implement delete")
end

#resources_find(roles_table, relation, role_name) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/rolify/adapters/base.rb', line 32

def resources_find(roles_table, relation, role_name)
 raise NotImplementedError.new("You must implement resources_find")
end

#role_classObject



8
9
10
# File 'lib/rolify/adapters/base.rb', line 8

def role_class
  @role_cname.constantize
end

#where(relation, args) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/rolify/adapters/base.rb', line 16

def where(relation, args)
  raise NotImplementedError.new("You must implement where")
end