class Scenic::Definition

@api private

Attributes

name[R]

Public Class Methods

new(name, version) click to toggle source
# File lib/scenic/definition.rb, line 4
def initialize(name, version)
  @name = name.to_s
  @version = version.to_i
end

Public Instance Methods

full_path() click to toggle source
# File lib/scenic/definition.rb, line 17
def full_path
  Rails.root.join(path)
end
path() click to toggle source
# File lib/scenic/definition.rb, line 21
def path
  File.join("db", "views", filename)
end
to_sql() click to toggle source
# File lib/scenic/definition.rb, line 9
def to_sql
  File.read(full_path).tap do |content|
    if content.empty?
      raise "Define view query in #{path} before migrating."
    end
  end
end
version() click to toggle source
# File lib/scenic/definition.rb, line 25
def version
  @version.to_s.rjust(2, "0")
end

Private Instance Methods

filename() click to toggle source
# File lib/scenic/definition.rb, line 33
def filename
  "#{UnaffixedName.for(name).tr(".", "_")}_v#{version}.sql"
end