Module: EasyTalk::RefHelper
- Defined in:
- lib/easy_talk/ref_helper.rb
Class Method Summary collapse
- .build_ref_schema(type, constraints) ⇒ Object
- .should_use_ref?(type, constraints) ⇒ Boolean
- .should_use_ref_for_type?(type, constraints) ⇒ Boolean
Class Method Details
.build_ref_schema(type, constraints) ⇒ Object
22 23 24 25 |
# File 'lib/easy_talk/ref_helper.rb', line 22 def self.build_ref_schema(type, constraints) # Remove ref and optional from constraints as they're not JSON Schema keywords { '$ref': type.ref_template }.merge(constraints.except(:ref, :optional)) end |
.should_use_ref?(type, constraints) ⇒ Boolean
7 8 9 |
# File 'lib/easy_talk/ref_helper.rb', line 7 def self.should_use_ref?(type, constraints) ModelHelper.easytalk_model?(type) && should_use_ref_for_type?(type, constraints) end |
.should_use_ref_for_type?(type, constraints) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/easy_talk/ref_helper.rb', line 11 def self.should_use_ref_for_type?(type, constraints) return false unless ModelHelper.easytalk_model?(type) # Per-property constraint takes precedence if constraints.key?(:ref) constraints[:ref] else EasyTalk.configuration.use_refs end end |