Sha256: d406d4d7ee5e594d0ecb2dcd0c8b9b1089fe14170697489315de9a105fcf59a0

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

module Goma
  module Generators
    module MailerHelpers
    private
      def resource_name
        @resource_name ||= begin
          if options[:resource_name].present?
            options[:resource_name].underscore.to_sym
          elsif Goma.config.scopes.count == 1
            Goma.config.scopes.first
          else
            for scope in Goma.config.scopes
              break scope if name =~ /^#{scope}/i
            end
          end
        end
      end

      def goma_config
        @goma_config ||= Goma.config_for[resource_name.to_sym] || Goma.config
      end

      def goma_actions
        @goma_actions ||= begin
          a = ActiveSupport::OrderedHash.new
          if goma_config.modules.include?(:confirmable) &&
            name == (goma_config.activation_mailer_name || goma_config.default_mailer_name)
            a[:activation_needed_email] = 'Activation instructions'
            a[:activation_success_email] = 'Your account is now activated.'
            if goma_config.email_confirmation_enabled &&
              name == (goma_config.email_confirmation_mailer_name || goma_config.default_mailer_name)
              a[:email_confirmation_needed_email] = 'Email confirmation instructions'
              a[:email_confirmation_success_email] = 'Your email is now changed'
            end
          end

          if goma_config.modules.include?(:lockable) && goma_config.unlock_strategies.include?(:email) &&
            name == (goma_config.unlock_token_mailer_name || goma_config.default_mailer_name)
            a[:unlock_token_email] = 'Unlock instructions'
          end

          if goma_config.modules.include?(:recoverable) &&
            name == (goma_config.reset_password_mailer_name || goma_config.default_mailer_name)
            a[:reset_password_email] = 'Reset password instructions'
          end
          a
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
goma-0.0.1.rc3 lib/generators/goma/helpers/mailer_helpers.rb
goma-0.0.1.rc2 lib/generators/goma/helpers/mailer_helpers.rb
goma-0.0.1.rc1 lib/generators/goma/helpers/mailer_helpers.rb
goma-0.0.1.gamma lib/generators/goma/helpers/mailer_helpers.rb
goma-0.0.1.beta lib/generators/goma/helpers/mailer_helpers.rb