Sha256: 62e52bb9a675feccd8568f30669a7b53fb90c98df5b12a021e6f1c3d153699d6

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

module Fx
  # @api private
  class Function
    include Comparable

    attr_reader :name, :definition
    delegate :<=>, to: :name

    def initialize(function_row)
      @name = function_row.fetch("name")
      @definition = function_row.fetch("definition")
    end

    def ==(other)
      name == other.name && definition == other.definition
    end

    def to_schema
      <<~SCHEMA.indent(2)
        create_function :#{name}, sql_definition: <<-'SQL'
        #{definition.indent(4).rstrip}
        SQL
      SCHEMA
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fx-0.8.0 lib/fx/function.rb