Module: Viewmaster::Request
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/viewmaster/request.rb
Instance Method Summary collapse
- #get_layout ⇒ Object
- #get_layout_from_store ⇒ Object
- #set_layout_from_store ⇒ Object
-
#user_layout ⇒ Object
returns either TemplateVersion.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
41 42 43 44 45 46 47 |
# File 'lib/viewmaster/request.rb', line 41 def method_missing(method, *args) if method.to_s.match(/^is_version_(\w+)[?]$/) user_layout.name == $1 else super end end |
Instance Method Details
#get_layout ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/viewmaster/request.rb', line 30 def get_layout if Viewmaster::Config.include?([:layout]) [:layout] else [:layout] = Viewmaster::Config.default_version.name end #logged_in? ? current_user.layout : cookies[:layout] end |
#get_layout_from_store ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/viewmaster/request.rb', line 22 def get_layout_from_store if t = Viewmaster::TemplateVersion.find( current_user.layout ) t else Viewmaster::Config.default_version end end |
#set_layout_from_store ⇒ Object
17 18 19 20 |
# File 'lib/viewmaster/request.rb', line 17 def set_layout_from_store return if current_user.blank? [:layout] = current_user.layout || Viewmaster::Config.default_version.name end |
#user_layout ⇒ Object
returns either TemplateVersion
11 12 13 14 15 |
# File 'lib/viewmaster/request.rb', line 11 def user_layout @stored_layout ||= get_layout # @stored_layout ||= logged_in? && current_user.layout Viewmaster::Config.include?(@stored_layout) ? Viewmaster::TemplateVersion.find( @stored_layout ) : Viewmaster::Config.default_version end |