Sha256: 306c117e85a67cf9ff1bd043078b2ebf537e34fda33cc6a51b1a2656fbf2b48e

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

module Hive
  
  # Tracks follows, mutes, and follow/mute resets.
  class Follow < Base
    self.table_name = :hive_follows
    self.primary_keys = %i(follower following)
    
    belongs_to :follower_account, foreign_key: :follower, class_name: 'Account'
    belongs_to :following_account, foreign_key: :following, class_name: 'Account'
    
    scope :state, lambda { |state_name, options = {invert: false}|
      state = case state_name
      when :reset then 0
      when :follow then 1
      when :mute then 2
      else; -1
      end
      
      if !!options[:invert]
        where.not(state: state)
      else
        where(state: state)
      end
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hivemind-ruby-0.1.0 lib/hive/models/follow.rb