Sha256: fe93bbf1e6d775c5c400ed6913261556e5e39ec1e9b20c9937576270770f55bb

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require_relative 'otp/presenter'
require_relative 'invitable/presenter'
require_relative 'standard/presenter'

module WebammToRails
  module Sources
    module Views
      module Devise
        class Presenter
          def initialize(waml_definition:)
            @waml_definition = waml_definition
          end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webamm_to_rails-7.0.1 lib/webamm_to_rails/sources/views/devise/presenter.rb
webamm_to_rails-7.0.0 lib/webamm_to_rails/sources/views/devise/presenter.rb