Sha256: cba301dd4ccf44610ad315ff9137c8a316fdea164b297fbcab409606fdf51ff7

Contents?: true

Size: 395 Bytes

Versions: 5

Compression:

Stored size: 395 Bytes

Contents

class Message < ActiveRecord::Base
  has_many :reports, :through => :logs
  has_many :logs
  validates_presence_of :value, :digest

  def to_s
    value
  end

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

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/app/models/message.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/models/message.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/models/message.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/models/message.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/models/message.rb