Class: ChinoRuby::Field

Inherits:
CheckValues show all
Defined in:
lib/chino_ruby/classes.rb

Overview

Class which defines the fields for the creation of a Schema or a UserSchema

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CheckValues

#check_boolean, #check_int, #check_json, #check_string

Constructor Details

#initialize(type, name, indexed) ⇒ Field

  • type: type of the field in the Schema/UserSchema. Ex: ‘string’

  • name: name of the field in the Schema/UserSchema

  • indexed: if true, the field will be indexed on the server. That means it can be used to make a search request



43
44
45
46
47
48
49
50
# File 'lib/chino_ruby/classes.rb', line 43

def initialize(type, name, indexed)
  check_string(type)
  check_string(name)
  check_boolean(indexed)
  self.type = type
  self.name = name
  self.indexed = indexed
end

Instance Attribute Details

#indexedObject

Returns the value of attribute indexed.



38
39
40
# File 'lib/chino_ruby/classes.rb', line 38

def indexed
  @indexed
end

#nameObject

Returns the value of attribute name.



38
39
40
# File 'lib/chino_ruby/classes.rb', line 38

def name
  @name
end

#typeObject

Returns the value of attribute type.



38
39
40
# File 'lib/chino_ruby/classes.rb', line 38

def type
  @type
end

Instance Method Details

#to_jsonObject

Returns the values as a json



53
54
55
# File 'lib/chino_ruby/classes.rb', line 53

def to_json
  return {"type": type, "name": name, "indexed": indexed}.to_json
end