Class: SourceMonitor::Configuration::AuthenticationSettings::Handler

Inherits:
Struct
  • Object
show all
Defined in:
lib/source_monitor/configuration/authentication_settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callableObject

Returns the value of attribute callable

Returns:

  • (Object)

    the current value of callable



6
7
8
# File 'lib/source_monitor/configuration/authentication_settings.rb', line 6

def callable
  @callable
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



6
7
8
# File 'lib/source_monitor/configuration/authentication_settings.rb', line 6

def type
  @type
end

Instance Method Details

#call(controller) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/source_monitor/configuration/authentication_settings.rb', line 7

def call(controller)
  return unless callable

  case type
  when :symbol
    controller.public_send(callable)
  when :callable
    arity = callable.arity
    if arity.zero?
      controller.instance_exec(&callable)
    else
      callable.call(controller)
    end
  end
end