Sha256: 639fbcb1154d9015e07923f5d772a7589e4ca6bfd038759f7e4d7b454f15628d

Contents?: true

Size: 599 Bytes

Versions: 4

Compression:

Stored size: 599 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
      Rails.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

4 entries across 4 versions & 1 rubygems

Version Path
scenic-1.5.5 lib/scenic/definition.rb
scenic-1.5.4 lib/scenic/definition.rb
scenic-1.5.3 lib/scenic/definition.rb
scenic-1.5.2 lib/scenic/definition.rb