Class: ApiSchema::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/api_schema/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Field.



6
7
8
9
10
11
12
13
# File 'lib/api_schema/field.rb', line 6

def initialize(type, name, options = {})
  @type = type
  @name = name
  @format = options.fetch(:format, nil)
  @required = options.fetch(:required, false)
  @description = options.fetch(:desc, '')
  @allowed_values = [*options.fetch(:allowed_values, nil)]
end

Instance Attribute Details

#allowed_valuesObject

Returns the value of attribute allowed_values.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def allowed_values
  @allowed_values
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def description
  @description
end

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def format
  @format
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def name
  @name
end

#requiredObject

Returns the value of attribute required.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def required
  @required
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/api_schema/field.rb', line 4

def type
  @type
end

Instance Method Details

#required?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/api_schema/field.rb', line 15

def required?
  required
end