module Refinery
  module <%= namespacing %>
    class Setting < Refinery::Core::BaseModel

      class << self
        def confirmation_body
          Refinery::Setting.find_or_set(:<%= singular_name %>_confirmation_body,
            "Thank you for your <%= singular_name.humanize.downcase %> %name%,\n\nThis email is a receipt to confirm we have received your <%= singular_name.humanize.downcase %> and we'll be in touch shortly.\n\nThanks."
          )
        end

        def confirmation_subject
          Refinery::Setting.find_or_set(:<%= singular_name %>_confirmation_subject,
                                        "Thank you for your <%= singular_name.humanize.downcase %>")
        end

        def confirmation_subject=(value)
          Refinery::Setting.set(:<%= singular_name %>_confirmation_subject, value)
        end

        def notification_recipients
          Refinery::Setting.find_or_set(:<%= singular_name %>_notification_recipients,
                                        (Role[:refinery].users.first.try(:email) if defined?(Role)).to_s)
        end

        def notification_subject
          Refinery::Setting.find_or_set(:<%= singular_name %>_notification_subject,
                                        "New <%= singular_name.humanize.downcase %> from your website")
        end
      end

    end
  end
end
