Class: Trebuchet::Strategy::UserId
- Defined in:
- lib/trebuchet/strategy/user_id.rb
Instance Attribute Summary collapse
-
#user_ids ⇒ Object
readonly
Returns the value of attribute user_ids.
Attributes inherited from Base
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(user_ids) ⇒ UserId
constructor
A new instance of UserId.
- #launch_at?(user, request = nil) ⇒ Boolean
- #to_s ⇒ Object
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_ids ⇒ Object (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
#export ⇒ Object
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
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_s ⇒ Object
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 |