Sha256: b0bc5e0e173d5e069959fd5f9050055de67c32df149b62e8fa960fdef89e8f2e
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module AgnosticBackend module Indexable class FieldType INTEGER = :integer DOUBLE = :double STRING = :string # literal string (i.e. should be matched exactly) STRING_ARRAY = :string_array TEXT = :text TEXT_ARRAY = :text_array DATE = :date # datetime BOOLEAN = :boolean STRUCT = :struct # a nested structure containing other values def self.all constants.map { |constant| const_get(constant) } end def self.exists?(type) all.include? type end attr_reader :type, :options def initialize(type, **options) raise "Type #{type} not supported" unless FieldType.exists? type @type = type @options = options end def nested? type == STRUCT end def matches?(type) self.type == type end def get_option(option_name) @options[option_name.to_sym] end def has_option(option_name) @options.has_key? option_name.to_sym end end end end
Version data entries
6 entries across 6 versions & 1 rubygems