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
# 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



19
20
21
# File 'lib/eco/api/organization/login_providers.rb', line 19

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

#any_optional?Boolean

Returns:

  • (Boolean)


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

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

#idsObject



29
30
31
# File 'lib/eco/api/organization/login_providers.rb', line 29

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)


62
63
64
# File 'lib/eco/api/organization/login_providers.rb', line 62

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

#namesObject



33
34
35
# File 'lib/eco/api/organization/login_providers.rb', line 33

def names
  @by_name.keys
end

#password_idObject



15
16
17
# File 'lib/eco/api/organization/login_providers.rb', line 15

def password_id
  to_id("password")
end

#to_id(name) ⇒ Object



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

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



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

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