Class: Pakyow::Data::Adapters::Sql::Migrators::Finalizer::Writer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pakyow/data/adapters/sql/migrators/finalizer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(root: false) ⇒ Writer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Writer.



44
45
46
# File 'lib/pakyow/data/adapters/sql/migrators/finalizer.rb', line 44

def initialize(root: false)
  @root, @content = root, String.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/pakyow/data/adapters/sql/migrators/finalizer.rb', line 64

def method_missing(name, *args, **kwargs, &block)
  method_call = "#{name} #{args_to_string(args, kwargs)}"

  if block_given?
    @content << <<~CONTENT
      #{method_call} do
      #{indent(Writer.new.tap { |writer| writer.instance_exec(&block) }.to_s)}
      end
    CONTENT
  else
    @content << <<~CONTENT
      #{method_call}
    CONTENT
  end
end

Instance Method Details

#to_aryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
# File 'lib/pakyow/data/adapters/sql/migrators/finalizer.rb', line 60

def to_ary
  [to_s]
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pakyow/data/adapters/sql/migrators/finalizer.rb', line 48

def to_s
  if @root
    <<~CONTENT
      change do
      #{indent(@content.strip)}
      end
    CONTENT
  else
    @content.strip
  end
end