Sha256: 8b66bcd251d82ec597b6f9a4be02e6966a2e1eaa3df29db136213bd5248f2e00

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

module ActsAsSaveable::Helpers

  # this helper provides methods that help find what words are
  # up saves and what words are down saves
  #
  # It can be called
  #
  # saveable_object.saveable_words.that_mean_true
  #
  module Words

    def saveable_words
      SaveableWords
    end

  end

  class SaveableWords

    def self.that_mean_true
      ['up', 'upsaved', 'like', 'liked', 'positive', 'yes', 'good', 'true', 1, true]
    end

    def self.that_mean_false
      ['down', 'downsaved', 'dislike', 'disliked', 'negative', 'no', 'bad', 'false', 0, false]
    end

    # check is word is a true or bad saved
    # if the word is unknown, then it counts it as a true/good
    # saved.  this exists to allow all saving to be good by default
    def self.meaning_of word
      !that_mean_false.include?(word)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_saveable-0.10.1 lib/acts_as_saveable/helpers/words.rb