Class: Spectifly::Json::Association
- Inherits:
-
Base::Association
- Object
- Base::EntityNode
- Base::Association
- Spectifly::Json::Association
- Defined in:
- lib/spectifly/json/association.rb
Instance Attribute Summary
Attributes inherited from Base::Association
Attributes inherited from Base::EntityNode
#attributes, #description, #example, #inherits_from, #name, #restrictions, #validations
Instance Method Summary collapse
Methods inherited from Base::Association
Methods inherited from Base::EntityNode
#display_type, #extract_attributes, #extract_restrictions, #initialize, #required?, #type, #unique?
Constructor Details
This class inherits a constructor from Spectifly::Base::Association
Instance Method Details
#to_h ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/spectifly/json/association.rb', line 4 def to_h fields = { :type => type, :required => required?, } [:description, :example, :restrictions].each do |opt| value = self.send(opt) if value && !value.empty? fields[opt] = value end end { name.to_sym => fields} end |