Class: Squasher::Render
- Inherits:
-
Object
- Object
- Squasher::Render
- Defined in:
- lib/squasher/render.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #each_schema_line(&block) ⇒ Object
-
#initialize(name, config) ⇒ Render
constructor
A new instance of Render.
- #render ⇒ Object
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/squasher/render.rb', line 9 def config @config end |
#name ⇒ Object (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 |
#render ⇒ Object
16 17 18 |
# File 'lib/squasher/render.rb', line 16 def render ERB.new(template("#{ name }.rb"), nil, '-').result(binding) end |