Sha256: 12f75614dc006670b84f891a80dbc75b819ebf8eb0ddfdbddc304471913f9d75

Contents?: true

Size: 772 Bytes

Versions: 5

Compression:

Stored size: 772 Bytes

Contents

module Ominous
  class Closer < ActiveRecord::Base
    attr_accessible :name, :url, :closure_method, :start_hidden, :message, :link_text
    
    CLOSURE_METHODS = {
      :reveal_hidden => 'Hides the current closers and reveals any hidden closers', 
      :close_and_dismiss_warning => 'Closes the warning message and tells server not to display warning again', 
      :redirect => 'Link to take user to closer.url without clearing the warning' 
    }    
    
    validates :name, :presence => true
    validates :closure_method, :inclusion => { :in => CLOSURE_METHODS.keys.collect(&:to_s) }
    
    def self.closure_methods
      CLOSURE_METHODS
    end
    
    def link_text
      super.blank? ? "click here to #{closure_method}".humanize : super
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ominous-0.1.3 app/models/ominous/closer.rb
ominous-0.1.2 app/models/ominous/closer.rb
ominous-0.1.1 app/models/ominous/closer.rb
ominous-0.1.0 app/models/ominous/closer.rb
ominous-0.0.5 app/models/ominous/closer.rb