Sha256: d75270a3796fd15f6de2c0e5987272427c680367ddd07b6c864e3d5e31364001
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
module WebammToRails module Sources module Models class DeviseDefinition class Presenter def initialize(table_name:, waml_definition:) @table_name = table_name @waml_definition = waml_definition end def render return unless authenticated? base_strategies = [ 'database_authenticatable', 'validatable', 'rememberable', 'recoverable', 'trackable' ] if auth_features.include?('allow_sign_up') base_strategies << 'registerable' base_strategies << 'confirmable' end if auth_features.include?('invitations') base_strategies << 'invitable' end if auth_features.include?('two_factor_authentication') base_strategies << 'otp_authenticatable' end "devise #{base_strategies.map { |strategy| ":#{strategy}" }.join(', ')}" end private def authenticated? return false if @waml_definition.authentication.blank? @waml_definition.authentication.map(&:table).include?(@table_name) end def auth_features @waml_definition.authentication.find { |auth| auth.table == @table_name }.features 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/models/devise_definition/presenter.rb |
webamm_to_rails-7.0.0 | lib/webamm_to_rails/sources/models/devise_definition/presenter.rb |