class Partializer::Partial

Attributes

action[R]
name[R]
ns[R]
path[R]

Public Class Methods

new(path, name) click to toggle source
# File lib/partializer/partial.rb, line 5
def initialize path, name
  @path = path unless path.blank?
  self.name = name
end

Public Instance Methods

name=(name) click to toggle source
# File lib/partializer/partial.rb, line 16
def name= name
  @name = name
  normalize!
end
path=(path_name) click to toggle source
# File lib/partializer/partial.rb, line 10
def path= path_name      
  raise ArgumentError, "Path is blank" if path_name.blank?
  @path = path_name.gsub /\\./, '/' 
  normalize!
end
to_partial_path() click to toggle source
# File lib/partializer/partial.rb, line 25
def to_partial_path
  view_path.gsub('.', '/')
end
view_path() click to toggle source
# File lib/partializer/partial.rb, line 21
def view_path
  [ns, action, path, name].compact.join('/')
end

Protected Instance Methods

normalize!() click to toggle source
# File lib/partializer/partial.rb, line 36
def normalize!
  if path =~ /\.#{name}$/
    norm = path.split('.')[0..-2].join('.')
    @path = norm unless norm.blank? 
  end
end
set_context(ns, action) click to toggle source
# File lib/partializer/partial.rb, line 31
def set_context ns, action
  @ns, @action = [ns, action]
  self
end