Class: Sapling::Memory::Feature
- Inherits:
-
Object
- Object
- Sapling::Memory::Feature
- Defined in:
- lib/sapling/memory.rb
Instance Attribute Summary collapse
-
#percentage ⇒ Object
Returns the value of attribute percentage.
-
#users ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
- #activate_percentage(percentage) ⇒ Object
- #activate_user(user) ⇒ Object
-
#active?(options = {}) ⇒ Boolean
see Sapling::API::Client.
- #deactivate_percentage ⇒ Object
- #deactivate_user(user) ⇒ Object
- #individually_active?(user) ⇒ Boolean
-
#initialize ⇒ Feature
constructor
A new instance of Feature.
- #percentage_active?(options = {}) ⇒ Boolean
Constructor Details
#initialize ⇒ Feature
Returns a new instance of Feature.
7 8 9 10 |
# File 'lib/sapling/memory.rb', line 7 def initialize @users={} self.percentage = 0 end |
Instance Attribute Details
#percentage ⇒ Object
Returns the value of attribute percentage.
5 6 7 |
# File 'lib/sapling/memory.rb', line 5 def percentage @percentage end |
#users ⇒ Object
Returns the value of attribute users.
5 6 7 |
# File 'lib/sapling/memory.rb', line 5 def users @users end |
Instance Method Details
#activate_percentage(percentage) ⇒ Object
34 35 36 |
# File 'lib/sapling/memory.rb', line 34 def activate_percentage(percentage) @percentage=percentage end |
#activate_user(user) ⇒ Object
26 27 28 |
# File 'lib/sapling/memory.rb', line 26 def activate_user(user) users[user.id]=true end |
#active?(options = {}) ⇒ Boolean
see Sapling::API::Client
13 14 15 16 |
# File 'lib/sapling/memory.rb', line 13 def active?(={}) = Util.() individually_active?([:user]) || percentage_active?() end |
#deactivate_percentage ⇒ Object
38 39 40 |
# File 'lib/sapling/memory.rb', line 38 def deactivate_percentage @percentage=0 end |
#deactivate_user(user) ⇒ Object
30 31 32 |
# File 'lib/sapling/memory.rb', line 30 def deactivate_user(user) users.delete(user.id) end |
#individually_active?(user) ⇒ Boolean
22 23 24 |
# File 'lib/sapling/memory.rb', line 22 def individually_active?(user) user && users[user.id] end |
#percentage_active?(options = {}) ⇒ Boolean
18 19 20 |
# File 'lib/sapling/memory.rb', line 18 def percentage_active?(={}) (Util.modded_context_id()) < percentage end |