Class: Trebuchet::Strategy::UserId

Inherits:
Base
  • Object
show all
Defined in:
lib/trebuchet/strategy/user_id.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#feature

Instance Method Summary collapse

Methods inherited from Base

#as_json, #feature_id, #inspect, #name, #needs_user?, strategy_name

Constructor Details

#initialize(user_ids) ⇒ UserId

Returns a new instance of UserId.



5
6
7
8
# File 'lib/trebuchet/strategy/user_id.rb', line 5

def initialize(user_ids)
  user_ids = Array(user_ids).flatten
  @user_ids = Set.new(user_ids)
end

Instance Attribute Details

#user_idsObject (readonly)

Returns the value of attribute user_ids.



3
4
5
# File 'lib/trebuchet/strategy/user_id.rb', line 3

def user_ids
  @user_ids
end

Instance Method Details

#exportObject



18
19
20
# File 'lib/trebuchet/strategy/user_id.rb', line 18

def export
  super @user_ids.to_a
end

#launch_at?(user, request = nil) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/trebuchet/strategy/user_id.rb', line 10

def launch_at?(user, request = nil)
  @user_ids.include?(user.id)
end

#to_sObject



14
15
16
# File 'lib/trebuchet/strategy/user_id.rb', line 14

def to_s
  "user ids (#{user_ids.empty? ? 'none' : user_ids.to_a.join(', ')})"
end