class EbayTrading::Schema::ClassTemplate

Attributes

name[R]

Public Class Methods

new(name) { |self| ... } click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 12
def initialize(name)
  @name = name
  yield self if block_given?
end

Public Instance Methods

exists?() click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 27
def exists?
  File.exists?(template_path)
end
load() click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 17
def load
  @template = load_template
  self
end
render(definition) click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 22
def render(definition)
  raise TemplateError, "No template has been loaded" if @template.nil?
  @template.result(definition.send(:get_binding))
end

Private Instance Methods

load_template() click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 32
def load_template
  raise(TemplateError, "Could not find template #{template_path}") unless exists?
  @template = ERB.new(File.read(template_path), nil, '-')
end
template_name(name) click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 41
def template_name(name)
  "#{template_dir}/#{name}.erb"
end
template_path() click to toggle source
# File lib/ebay_trading/schema/mapper/class_template.rb, line 37
def template_path
  template_name(@name)
end