class Yori::Schema::V3::Components
Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.
Constants
- VALID_COMPONENTS
Public Class Methods
register_component(id, component, key, value = nil, &block)
click to toggle source
# File lib/yori/schema/v3/components.rb, line 60 def register_component(id, component, key, value = nil, &block) @registered_components ||= {} @registered_components[id] ||= {} @registered_components[id][component.to_s] ||= {} @registered_components[id][component.to_s][key.to_s] = proc { check_and_send!(component, key, value, &block) } end
registered_components()
click to toggle source
# File lib/yori/schema/v3/components.rb, line 56 def registered_components @registered_components ||= {} end
Public Instance Methods
check_and_send!(component, key, value, &block)
click to toggle source
# File lib/yori/schema/v3/components.rb, line 50 def check_and_send!(component, key, value, &block) raise Yori::Errors::UnknownComponentError, "Unknown component: #{component}" unless VALID_COMPONENTS.include?(component.to_s) send(component, key, value, &block) end
merge_registered!()
click to toggle source
# File lib/yori/schema/v3/components.rb, line 40 def merge_registered! components ||= self.class.registered_components[id] components.flat_map { |_component, procs| procs.values } .each do |block| instance_eval(&block) end end