Sha256: 9d9b565a761c4d211bcfbf3e32f7f144ec3430de13448fee13c35603914cc697

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Mention
  class Alert
    include Virtus.model

    attribute :id, String
    attribute :name, String
    attribute :primary_keyword, String
    attribute :included_keywords, Array[String]
    attribute :excluded_keywords, Array[String]
    attribute :required_keywords, Array[String]
    attribute :noise_detection, Boolean, default: true
    attribute :sentiment_analysis, Boolean, default: false
    attribute :languages, Array[String], default: ['en']
    attribute :sources, Array[String], default: ["web","facebook","twitter","news","blogs","videos","forums","images"]
    attribute :shares, Array[Share], default: []

    def remove_from(account)
      share = share_for(account)
      account.remove_alert(self, share)
    end

    def mentions(account, params = {})
      account.fetch_mentions(self, params)
    end

    private
    def share_for(account)
      found = shares.find{|share| share.account_id}
      raise Error.new("could not find share for account #{account.id}") if found.nil?
      found
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mention-api-0.1.0 lib/mention/alert.rb
mention-api-0.0.3 lib/mention/alert.rb
mention-api-0.0.2 lib/mention/alert.rb