Module: MSFL::Sinatra::Helpers
- Defined in:
- lib/msfl/sinatra.rb
Instance Method Summary collapse
-
#msfl_filter(params = nil) ⇒ Object
This method returns the valid MSFL filter.
-
#msfl_valid?(params) ⇒ Bool
This method extracts the dataset name and filter from the Sinatra params.
Instance Method Details
#msfl_filter(params = nil) ⇒ Object
This method returns the valid MSFL filter. If the valid filter has already been extracted from the parameters it is returned, otherwise if the optional params argument is specified it will be sent to MSFL::Sinatra.validate and if the validation is successful the valid filter is returned. If the valid filter still cannot be determined then the method raises an ArgumentError.
76 77 78 79 80 81 82 83 84 |
# File 'lib/msfl/sinatra.rb', line 76 def msfl_filter(params = nil) filter = Sinatra.valid_filter if filter.nil? Sinatra.validate params filter = Sinatra.valid_filter end raise ArgumentError, "A valid filter could not be located in msfl_filter." if filter.nil? filter end |
#msfl_valid?(params) ⇒ Bool
This method extracts the dataset name and filter from the Sinatra params. It also performs semantic validation of the filter relative to the dataset.
The method also has the side effect, when the filter is valid or setting the valid_filter singleton class instance variable valid_filter to the Ruby-ified parsed filter.
63 64 65 |
# File 'lib/msfl/sinatra.rb', line 63 def msfl_valid?(params) Sinatra.validate params end |