Module: EasyTalk::RefHelper
- Extended by:
- T::Sig
- 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
28 29 30 31 |
# File 'lib/easy_talk/ref_helper.rb', line 28 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
11 12 13 |
# File 'lib/easy_talk/ref_helper.rb', line 11 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
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/easy_talk/ref_helper.rb', line 16 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 |