Class: Message

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/message.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_create(val) ⇒ Object


14
15
16
17
# File 'app/models/message.rb', line 14

def self.find_or_create val
  digest = Digest::SHA1.hexdigest(val)
  Message.where(:digest => digest).first || Message.create(:value => val, :digest => digest)
end

Instance Method Details

#as_json(options = {}) ⇒ Object


10
11
12
# File 'app/models/message.rb', line 10

def as_json(options={})
  {:message => value }
end

#to_sObject


6
7
8
# File 'app/models/message.rb', line 6

def to_s
  value
end