Module: Cream::Helper::Role::Labels
- Defined in:
- lib/cream/helper/role.rb
Class Method Summary collapse
- .extract(options) ⇒ Object
- .is_guest?(current_user) ⇒ Boolean
- .is_not_guest?(current_user) ⇒ Boolean
- .logged_in_check(state, current_user) ⇒ Object
- .logged_in_labels ⇒ Object
- .logged_out_check(state, current_user) ⇒ Object
- .logged_out_labels ⇒ Object
- .state_check(state, current_user) ⇒ Object
Class Method Details
.extract(options) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/cream/helper/role.rb', line 134 def extract case when Symbol return :logged_in if logged_in_labels.include?() return :logged_out if logged_out_labels.include?() when Hash return :logged_in if logged_in_labels.any? {|lab| [lab] } return :logged_out if logged_out_labels.any? {|lab| [lab] } end raise ArgumentException, "Unknown option #{}" end |
.is_guest?(current_user) ⇒ Boolean
162 163 164 |
# File 'lib/cream/helper/role.rb', line 162 def is_guest? current_user current_user && current_user.is?(:guest) end |
.is_not_guest?(current_user) ⇒ Boolean
158 159 160 |
# File 'lib/cream/helper/role.rb', line 158 def is_not_guest? current_user !current_user || (current_user && !current_user.is?(:guest)) end |
.logged_in_check(state, current_user) ⇒ Object
150 151 152 |
# File 'lib/cream/helper/role.rb', line 150 def logged_in_check state, current_user state == :logged_in && is_not_guest?(current_user) end |
.logged_in_labels ⇒ Object
166 167 168 |
# File 'lib/cream/helper/role.rb', line 166 def logged_in_labels [:logged_in, :signed_in, :not_logged_out, :not_signed_out] end |
.logged_out_check(state, current_user) ⇒ Object
154 155 156 |
# File 'lib/cream/helper/role.rb', line 154 def logged_out_check state, current_user state == :logged_out && is_guest?(current_user) end |
.logged_out_labels ⇒ Object
170 171 172 |
# File 'lib/cream/helper/role.rb', line 170 def logged_out_labels [:logged_out, :signed_out, :not_logged_in, :not_signed_in] end |
.state_check(state, current_user) ⇒ Object
146 147 148 |
# File 'lib/cream/helper/role.rb', line 146 def state_check state, current_user logged_in_check(state, current_user) || logged_out_check(state, current_user) end |