Class: Apigen::ObjectProperty
- Inherits:
-
Object
- Object
- Apigen::ObjectProperty
- Defined in:
- lib/apigen/models/object_property.rb
Overview
ObjectProperty is a specific property in an ObjectType.
Instance Attribute Summary collapse
- #required(required) ⇒ Object
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #explain(&block) ⇒ Object
-
#initialize(type, description = nil, example = nil) ⇒ ObjectProperty
constructor
A new instance of ObjectProperty.
- #required? ⇒ Boolean
Constructor Details
#initialize(type, description = nil, example = nil) ⇒ ObjectProperty
Returns a new instance of ObjectProperty.
14 15 16 17 18 19 |
# File 'lib/apigen/models/object_property.rb', line 14 def initialize(type, description = nil, example = nil) @type = type @description = description @example = example @required = true end |
Instance Attribute Details
#required(required) ⇒ Object
21 22 23 24 |
# File 'lib/apigen/models/object_property.rb', line 21 def required(required) @required = required self end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/apigen/models/object_property.rb', line 9 def type @type end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/apigen/models/object_property.rb', line 35 def ==(other) other.is_a?(ObjectProperty) && type == other.type && required? == other.required? && description == other.description && example == other.example end |
#explain(&block) ⇒ Object
30 31 32 33 |
# File 'lib/apigen/models/object_property.rb', line 30 def explain(&block) raise 'You must pass a block to `explain`.' unless block_given? instance_eval(&block) end |
#required? ⇒ Boolean
26 27 28 |
# File 'lib/apigen/models/object_property.rb', line 26 def required? @required end |