class Railroader::RenderPath

Attributes

path[R]

Public Class Methods

new() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 5
def initialize
  @path = []
end

Public Instance Methods

add_controller_render(controller_name, method_name, line, file) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 9
def add_controller_render controller_name, method_name, line, file
  method_name ||= ""

  @path << { :type => :controller,
             :class => controller_name.to_sym,
             :method => method_name.to_sym,
             :line => line,
             :file => file
            }

  self
end
add_template_render(template_name, line, file) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 22
def add_template_render template_name, line, file
  @path << { :type => :template,
             :name => template_name.to_sym,
             :line => line,
             :file => file
           }

  self
end
each(&block) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 62
def each &block
  @path.each(&block)
end
include_any_method?(method_names) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 48
def include_any_method? method_names
  names = method_names.map(&:to_sym)

  @path.any? do |loc|
    loc[:type] == :controller and names.include? loc[:method]
  end
end
include_controller?(klass) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 40
def include_controller? klass
  klass = klass.to_sym

  @path.any? do |loc|
    loc[:type] == :controller and loc[:class] == klass
  end
end
include_template?(name) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 32
def include_template? name
  name = name.to_sym

  @path.any? do |loc|
    loc[:type] == :template and loc[:name] == name
  end
end
initialize_copy(original) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 102
def initialize_copy original
  @path = original.path.dup
  self
end
join(*args) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 66
def join *args
  self.to_a.join(*args)
end
last() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 85
def last
  self.to_a.last
end
length() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 70
def length
  @path.length
end
rendered_from_controller?() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 56
def rendered_from_controller?
  @path.any? do |loc|
    loc[:type] == :controller
  end
end
to_a() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 74
def to_a
  @path.map do |loc|
    case loc[:type]
    when :template
      "Template:#{loc[:name]}"
    when :controller
      "#{loc[:class]}##{loc[:method]}"
    end
  end
end
to_json(*args) click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 97
def to_json *args
  require 'json'
  JSON.generate(@path)
end
to_s() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 89
def to_s
  self.to_a.to_s
end
to_sym() click to toggle source
# File lib/railroader/processors/lib/render_path.rb, line 93
def to_sym
  self.to_s.to_sym
end