class MightyJSON::Type::Literal

Public Class Methods

new(value) click to toggle source
# File lib/mighty_json/type.rb, line 98
def initialize(value)
  @value = value
end

Public Instance Methods

compile(var:, path:) click to toggle source
# File lib/mighty_json/type.rb, line 106
      def compile(var:, path:)
        v = var.cur
        <<~END
          raise Error.new(path: #{path.inspect}, type: #{self.to_s.inspect}, value: #{v}) unless #{@value.inspect} == #{v}
          #{v}
        END
      end
to_s() click to toggle source
# File lib/mighty_json/type.rb, line 102
def to_s
  "literal(#{@value})"
end