Class: Squasher::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/squasher/render.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config) ⇒ Render

Returns a new instance of Render.



11
12
13
14
# File 'lib/squasher/render.rb', line 11

def initialize(name, config)
  @name = name
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/squasher/render.rb', line 9

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/squasher/render.rb', line 9

def name
  @name
end

Class Method Details

.render(*args) ⇒ Object



5
6
7
# File 'lib/squasher/render.rb', line 5

def self.render(*args)
  new(*args).render
end

Instance Method Details

#each_schema_line(&block) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/squasher/render.rb', line 20

def each_schema_line(&block)
  File.open(config.schema_file, 'r') do |stream|
    if @config.set?(:sql)
      stream_structure(stream, &block)
    else
      stream_schema(stream, &block)
    end
  end
end

#renderObject



16
17
18
# File 'lib/squasher/render.rb', line 16

def render
  ERB.new(template("#{ name }.rb"), nil, '-').result(binding)
end