Class: Entitlements::Models::Action

Inherits:
Object
  • Object
show all
Includes:
Contracts::Core
Defined in:
lib/entitlements.rb,
lib/entitlements/models/action.rb

Constant Summary collapse

C =
::Contracts

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Contracts::Core

common, extended, included

Constructor Details

#initialize(dn, existing, updated, ou, ignored_users: Set.new) ⇒ Action

Returns a new instance of Action.



17
18
19
20
21
22
23
24
# File 'lib/entitlements/models/action.rb', line 17

def initialize(dn, existing, updated, ou, ignored_users: Set.new)
  @dn = dn
  @existing = existing
  @updated = updated
  @ou = ou
  @implementation = nil
  @ignored_users = ignored_users
end

Instance Attribute Details

#dnObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def dn
  @dn
end

#existingObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def existing
  @existing
end

#ignored_usersObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def ignored_users
  @ignored_users
end

#implementationObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def implementation
  @implementation
end

#ouObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def ou
  @ou
end

#updatedObject (readonly)

Element readers.



27
28
29
# File 'lib/entitlements/models/action.rb', line 27

def updated
  @updated
end

Instance Method Details

#add_implementation(data) ⇒ Object



75
76
77
78
# File 'lib/entitlements/models/action.rb', line 75

def add_implementation(data)
  @implementation ||= []
  @implementation << data
end

#change_typeObject



31
32
33
34
35
# File 'lib/entitlements/models/action.rb', line 31

def change_type
  return :add if existing.nil?
  return :delete if updated.nil?
  :update
end

#configObject



43
44
45
# File 'lib/entitlements/models/action.rb', line 43

def config
  Entitlements.config["groups"].fetch(ou)
end

#ou_typeObject



53
54
55
# File 'lib/entitlements/models/action.rb', line 53

def ou_type
  config["type"] || "ldap"
end

#short_nameObject



63
64
65
# File 'lib/entitlements/models/action.rb', line 63

def short_name
  dn =~ /\A(\w+)=(.+?),/ ? Regexp.last_match(2) : dn
end