Class: Sapling::Util
- Inherits:
-
Object
- Object
- Sapling::Util
- Defined in:
- lib/sapling/util.rb
Constant Summary collapse
- CONTEXT_ID_ONLY_ENABLED_IF_100_PERCENT_ENABLED =
99
Class Method Summary collapse
- .context_id(options) ⇒ Object
- .modded_context_id(options) ⇒ Object
- .normalized_options(options, controller = nil) ⇒ Object
Class Method Details
.context_id(options) ⇒ Object
6 7 8 |
# File 'lib/sapling/util.rb', line 6 def context_id() [:context_id] || ((u=[:user]) && u.id) end |
.modded_context_id(options) ⇒ Object
9 10 11 |
# File 'lib/sapling/util.rb', line 9 def modded_context_id() ((cid=context_id()) && (cid%100)) || CONTEXT_ID_ONLY_ENABLED_IF_100_PERCENT_ENABLED end |
.normalized_options(options, controller = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sapling/util.rb', line 13 def (,controller=nil) [:user] ||= controller.current_user if controller [:user_id] ||= [:user].id if [:user] [:context_id] ||= [:user_id] end |