Sha256: 23aac2b209dfb954b906f642624958a333710e8a6be5cdaed94bc57cfe680904

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module PokeJs
  module Controller
    extend ActiveSupport::Concern
    included do
      helper_method :poke_js_template
      helper_method :extract_template
    end

    def poke_js_template
      extract_template(@poke_js_template)
    end

    protected
    def extract_template(template)
      extracted_template = [controller_path, action_name]
      if template
        array = if template.class == Array
                  template
                else
                  split = template.to_s.split('/')
                  template_controller = split[0..-2]
                  unless template_controller.empty?
                    template_controller = [template_controller.join('/')]
                  end
                  template_controller + [split.last]
                end
        if array.size == 1
          extracted_template[1] = array.first
        else
          extracted_template = array
        end
      end
      extracted_template
    end
  end
end

::ActionController::Base.send :include, PokeJs::Controller

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
poke_js-0.1.10 lib/poke_js/controller.rb
poke_js-0.1.9 lib/poke_js/controller.rb
poke_js-0.1.8 lib/poke_js/controller.rb
poke_js-0.1.7 lib/poke_js/controller.rb