Class: Eco::API::Organization::LoginProviders

Inherits:
Language::Models::Collection show all
Defined in:
lib/eco/api/organization/login_providers.rb

Constant Summary

Constants inherited from Language::Models::Collection

Language::Models::Collection::BASIC_METHODS, Language::Models::Collection::EXTENDED_METHODS

Instance Method Summary collapse

Methods inherited from Language::Models::Collection

#<, #<<, #attr, #attr?, attr_collection, attr_presence, #attrs, attrs_create_method, #contains, #delete!, #each, #empty, #empty?, #exclude, #group_by, #length, #merge, #new, #newFrom, #present, #present_all?, #present_some?, #remove, #to_c, #to_h, #unique_attrs, #update

Constructor Details

#initialize(login_providers = [], klass: Ecoportal::API::Internal::LoginProvider, factory: nil) ⇒ LoginProviders

Returns a new instance of LoginProviders.



8
9
10
11
12
13
14
15
# File 'lib/eco/api/organization/login_providers.rb', line 8

def initialize( = [], klass: Ecoportal::API::Internal::LoginProvider, factory: nil)
  @klass       = Ecoportal::API::Internal::LoginProvider
  @caches_init = false

  super(, klass: @klass)

  init_caches
end

Instance Method Details

#activeObject



21
22
23
# File 'lib/eco/api/organization/login_providers.rb', line 21

def active
  select {|lp| lp != "disabled"}
end

#any_optional?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/eco/api/organization/login_providers.rb', line 25

def any_optional?
  active.any? do |lp|
    lp.enabled_for = "some"
  end
end

#idsObject



31
32
33
# File 'lib/eco/api/organization/login_providers.rb', line 31

def ids
  @by_id.keys
end

#login_provider(id_name_type) ⇒ Object

Parameters:

  • id_name_type (String, Symbol)
    • String to refer to the login provider name or id
    • Symbol to refer to the login providr type (i.e. :password, :sso)


64
65
66
# File 'lib/eco/api/organization/login_providers.rb', line 64

def (id_name_type)
  @by_id[(id_name_type)]
end

#namesObject



35
36
37
# File 'lib/eco/api/organization/login_providers.rb', line 35

def names
  @by_name.keys
end

#password_idObject



17
18
19
# File 'lib/eco/api/organization/login_providers.rb', line 17

def password_id
  to_id("password")
end

#to_id(name) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/eco/api/organization/login_providers.rb', line 39

def to_id(name)
  case name
  when Enumerable
    name.map do |n|
      (n)&.id
    end.compact
  else
    (name)&.id
  end
end

#to_name(id) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/eco/api/organization/login_providers.rb', line 50

def to_name(id)
  case name
  when Enumerable
    id.map do |i|
      (i)&.name
    end.compact
  else
    (id)&.name
  end
end