Class: Sekisyo::WhitelistDetails::Properties
- Inherits:
-
Object
- Object
- Sekisyo::WhitelistDetails::Properties
- Defined in:
- lib/sekisyo/whitelist_details/properties.rb
Overview
Sekisyo WhitelistDetails Path is a definition object for each properties in the whitelist.
Instance Method Summary collapse
-
#initialize(properties = {}) ⇒ Properties
constructor
A new instance of Properties.
- #valid?(params) ⇒ true, false
Constructor Details
#initialize(properties = {}) ⇒ Properties
Returns a new instance of Properties.
11 12 13 14 15 16 |
# File 'lib/sekisyo/whitelist_details/properties.rb', line 11 def initialize(properties = {}) @permit_keys = properties.keys @properties = properties.map do |k, v| Sekisyo::Validator.new(k, v || {}) end end |
Instance Method Details
#valid?(params) ⇒ true, false
23 24 25 26 27 28 29 30 |
# File 'lib/sekisyo/whitelist_details/properties.rb', line 23 def valid?(params) return false unless params.is_a? Hash return false unless params == params.slice(*@permit_keys) params.all? do |k, v| @properties.find { |validator| validator.key == k }&.valid?(v) end end |