Sha256: c04095666d5fd97c98480e1bfd6f75524df61ee160915119c370e13a418e54ca

Contents?: true

Size: 598 Bytes

Versions: 2

Compression:

Stored size: 598 Bytes

Contents

module Scenic
  # @api private
  class Definition
    def initialize(name, version)
      @name = name
      @version = version.to_i
    end

    def to_sql
      File.read(full_path).tap do |content|
        if content.empty?
          raise "Define view query in #{path} before migrating."
        end
      end
    end

    def full_path
      Jets.root.join(path)
    end

    def path
      File.join("db", "views", filename)
    end

    def version
      @version.to_s.rjust(2, "0")
    end

    private

    def filename
      "#{@name.to_s.tr('.', '_')}_v#{version}.sql"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scenic-jets-1.5.5 lib/scenic/definition.rb
scenic-jets-1.5.4 lib/scenic/definition.rb