Class: Apipie::ResponseDescriptionAdapter::PropDesc::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/response_description_adapter.rb

Overview

a ResponseDescriptionAdapter::PropDesc::Validator pretends to be an Apipie::Validator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_type, enum_values = nil, sub_properties = nil) ⇒ Validator

Returns a new instance of Validator.



63
64
65
66
67
68
# File 'lib/apipie/response_description_adapter.rb', line 63

def initialize(expected_type, enum_values = nil, sub_properties = nil)
  @expected_type = expected_type
  @enum_values = enum_values
  @is_enum = !!enum_values
  @sub_properties = sub_properties
end

Instance Attribute Details

#expected_typeObject (readonly)

Returns the value of attribute expected_type.



57
58
59
# File 'lib/apipie/response_description_adapter.rb', line 57

def expected_type
  @expected_type
end

Instance Method Details

#[](key) ⇒ Object



59
60
61
# File 'lib/apipie/response_description_adapter.rb', line 59

def [](key)
  self.send(key) if self.respond_to?(key.to_s)
end

#is_enum?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/apipie/response_description_adapter.rb', line 70

def is_enum?
  !!@is_enum
end

#params_orderedObject



78
79
80
81
# File 'lib/apipie/response_description_adapter.rb', line 78

def params_ordered
  raise "Only validators with expected_type 'object' can have sub-properties" unless @expected_type == 'object'
  @sub_properties
end

#valuesObject



74
75
76
# File 'lib/apipie/response_description_adapter.rb', line 74

def values
  @enum_values
end