Class: Flame::Validators::RouteArgumentsValidator
- Inherits:
-
Object
- Object
- Flame::Validators::RouteArgumentsValidator
- Defined in:
- lib/flame/validators.rb
Overview
Compare arguments from path and from controller’s action
Instance Method Summary collapse
-
#initialize(ctrl, path, action) ⇒ RouteArgumentsValidator
constructor
A new instance of RouteArgumentsValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(ctrl, path, action) ⇒ RouteArgumentsValidator
Returns a new instance of RouteArgumentsValidator.
9 10 11 12 13 |
# File 'lib/flame/validators.rb', line 9 def initialize(ctrl, path, action) @ctrl = ctrl @path = Flame::Path.new(path) @action = action end |
Instance Method Details
#valid? ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flame/validators.rb', line 15 def valid? ## Get hash of any extra arguments extra = %i[req opt].find do |type| found = extra_arguments(type).find do |place, args| break { place: place, type: type, args: args } if args.any? end break found if found end ## Return true if no any extra argument return true unless extra ## Raise error with extra arguments raise Errors::RouteArgumentsError.new(@ctrl, @action, @path, extra) end |