Module: Resourcelogic::Context::Methods
- Defined in:
- lib/resourcelogic/context.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
12 13 14 15 |
# File 'lib/resourcelogic/context.rb', line 12 def self.included(klass) klass.helper_method :context, :contexts, :contexts_url_parts klass.hide_action :context, :contexts end |
Instance Method Details
#context ⇒ Object
17 18 19 |
# File 'lib/resourcelogic/context.rb', line 17 def context @context ||= contexts.last end |
#contexts ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/resourcelogic/context.rb', line 21 def contexts return @contexts if defined?(@contexts) path_parts = request.path.split("/") path_parts.shift @contexts = [] path_parts.each_with_index do |part, index| break if model_name_from_path_part(part.split(".").first) == model_name @contexts << (part.to_i > 0 ? @contexts.pop.to_s.singularize.to_sym : part.underscore.to_sym) end @contexts end |