Class: WebammToRails::Sources::Views::Devise::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/webamm_to_rails/sources/views/devise/presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(waml_definition:) ⇒ Presenter

Returns a new instance of Presenter.



10
11
12
# File 'lib/webamm_to_rails/sources/views/devise/presenter.rb', line 10

def initialize(waml_definition:)
  @waml_definition = waml_definition
end

Instance Method Details

#collectionObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/webamm_to_rails/sources/views/devise/presenter.rb', line 14

def collection
  return [] if @waml_definition.authentication.blank?

  views_collection = []

  @waml_definition.authentication.each do |authentication|
    views_collection |= ::WebammToRails::Sources::Views::Devise::Standard::Presenter.new(table_name: authentication.table).collection

    if authentication.features.include?('invitations')
      views_collection |= ::WebammToRails::Sources::Views::Devise::Invitable::Presenter.new(table_name: authentication.table).collection
    end
  end

  if @waml_definition.authentication.any? { |authentication| authentication.features.include?('two_factor_authentication') }
    views_collection |= ::WebammToRails::Sources::Views::Devise::Otp::Presenter.new.collection
  end

  views_collection
end