Sha256: fd8e4615dca99d08c4fc35c93eaa1c1be822d9b02075d114b98135302438d9b4

Contents?: true

Size: 582 Bytes

Versions: 4

Compression:

Stored size: 582 Bytes

Contents

module Tweetable
  class Link < Persistable
    URL_PATTERN = /(http:\S+)/ix
    
    attribute :created_at
    attribute :updated_at
    attribute :url
    attribute :long_url  
    
    index :url
    index :long_url
    
    # set :messages, Tweetable::Message
    set :users, Tweetable::User
    counter :count
    
    def increment_usage_count(user)
      return false if (user.nil? || self.users.include?(user))
      users.add(user)
      self.incr(:count)
    end
    
    protected
    
    def validate
      assert_present :url
      assert_unique :url
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tweetable-0.1.14 lib/tweetable/link.rb
tweetable-0.1.13 lib/tweetable/link.rb
tweetable-0.1.11 lib/tweetable/link.rb
tweetable-0.1.10 lib/tweetable/link.rb