Class: Fluent::Json::Schema::Terms::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/json/schema/terms/field.rb

Direct Known Subclasses

Bool, Fk, Num, Obj, Str

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Field

Returns a new instance of Field.



8
9
10
11
12
13
14
# File 'lib/fluent/json/schema/terms/field.rb', line 8

def initialize(name, options={})
  @name = name
  @required = options[:required]
  @constraints = []

  self.set(options)
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def constraints
  @constraints
end

#defaultObject (readonly)

Returns the value of attribute default.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def default
  @default
end

#enumObject (readonly)

Returns the value of attribute enum.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def enum
  @enum
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def required
  @required
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/fluent/json/schema/terms/field.rb', line 6

def version
  @version
end

Instance Method Details

#as_json(options = {}) ⇒ Object



31
32
33
# File 'lib/fluent/json/schema/terms/field.rb', line 31

def as_json(options={})
  return options.merge(self.as_json_fragment(:default, :enum))
end

#mandateObject



16
17
18
19
# File 'lib/fluent/json/schema/terms/field.rb', line 16

def mandate
  @required = true
  return self
end

#optionaliseObject



21
22
23
24
# File 'lib/fluent/json/schema/terms/field.rb', line 21

def optionalise
  @required = false
  return self
end

#set(options = {}) ⇒ Object



26
27
28
29
# File 'lib/fluent/json/schema/terms/field.rb', line 26

def set(options={})
  @enum = options[:enum]
  @default = options[:default]
end