Class: Ebay::Schema::ClassTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/ebay/schema/mapper/class_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) {|_self| ... } ⇒ ClassTemplate

Returns a new instance of ClassTemplate.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
# File 'lib/ebay/schema/mapper/class_template.rb', line 12

def initialize(name)
  @name = name
  yield self if block_given?
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/ebay/schema/mapper/class_template.rb', line 11

def name
  @name
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ebay/schema/mapper/class_template.rb', line 27

def exists?
  File.exists?(template_path)
end

#loadObject



17
18
19
20
# File 'lib/ebay/schema/mapper/class_template.rb', line 17

def load
  @template = load_template
  self
end

#render(definition) ⇒ Object

Raises:



22
23
24
25
# File 'lib/ebay/schema/mapper/class_template.rb', line 22

def render(definition)
  raise TemplateError, "No template has been loaded" if @template.nil?
  @template.result(definition.send(:binding))
end