Class: Sekisyo::WhitelistDetails::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/sekisyo/whitelist_details/method.rb

Overview

Sekisyo WhitelistDetails Method is a definition object for each HTTP method of a specific path in the whitelist.

Instance Method Summary collapse

Constructor Details

#initialize(object = {}) ⇒ Method

Returns a new instance of Method.

Parameters:

  • object (Hash) (defaults to: {})

    Hash object with array values with :required key and Hash values with :properties key.



14
15
16
17
18
19
# File 'lib/sekisyo/whitelist_details/method.rb', line 14

def initialize(object = {})
  @required = object.fetch('required', []).flat_map do |attr|
    attr.is_a?(Hash) ? transform_required_keys(attr) : [[attr]]
  end
  @properties = Sekisyo::WhitelistDetails::Properties.new(object['properties'])
end

Instance Method Details

#valid?(params) ⇒ true, false

Parameters:

  • params (Hash)

    Request parameters.

Returns:

  • (true, false)


26
27
28
# File 'lib/sekisyo/whitelist_details/method.rb', line 26

def valid?(params)
  required_validate(params) && @properties.valid?(params)
end