Module: MediaTypes::Dsl::ClassMethods
- Defined in:
- lib/media_types/dsl.rb
Instance Method Summary collapse
- #register ⇒ Object
- #to_constructable ⇒ Object
- #valid?(output, media_type = to_constructable, **opts) ⇒ Boolean
- #validatable?(media_type = to_constructable) ⇒ Boolean
- #validate!(output, media_type = to_constructable, **opts) ⇒ Object
Instance Method Details
#register ⇒ Object
41 42 43 44 45 46 |
# File 'lib/media_types/dsl.rb', line 41 def register registrations.to_a.map do |registerable| MediaTypes.register(registerable) registerable end end |
#to_constructable ⇒ Object
23 24 25 26 27 |
# File 'lib/media_types/dsl.rb', line 23 def to_constructable media_type_constructable.dup.tap do |constructable| constructable.__setobj__(self) end end |
#valid?(output, media_type = to_constructable, **opts) ⇒ Boolean
29 30 31 |
# File 'lib/media_types/dsl.rb', line 29 def valid?(output, media_type = to_constructable, **opts) validations.find(String(media_type)).valid?(output, backtrace: ['.'], **opts) end |
#validatable?(media_type = to_constructable) ⇒ Boolean
37 38 39 |
# File 'lib/media_types/dsl.rb', line 37 def validatable?(media_type = to_constructable) validations.find(String(media_type), -> { nil }) end |
#validate!(output, media_type = to_constructable, **opts) ⇒ Object
33 34 35 |
# File 'lib/media_types/dsl.rb', line 33 def validate!(output, media_type = to_constructable, **opts) validations.find(String(media_type)).validate(output, backtrace: ['.'], **opts) end |