Class: EML::Parameters

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/eml/parameters.rb

Direct Known Subclasses

UK::Parameters

Constant Summary collapse

ENDPOINT_CLASS_TYPE =
"Parameters"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Parameters

Returns a new instance of Parameters.



10
11
12
13
# File 'lib/eml/parameters.rb', line 10

def initialize(params)
  assign_params(params)
  validate_required_params_presence
end

Class Method Details

.convert(resource_class, endpoint, params) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/eml/parameters.rb', line 27

def convert(resource_class, endpoint, params)
  endpoint_class = EML::EndpointClass.(
    class_type: ENDPOINT_CLASS_TYPE, resource_class: resource_class,
    endpoint: endpoint
  )

  convert_with_endpoint_class(
    endpoint: endpoint, endpoint_class: endpoint_class,
    resource_class: resource_class, params: params
  )
end

Instance Method Details

#to_hObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/eml/parameters.rb', line 62

def to_h
  instance_variables.each_with_object({}) do |variable_name, params|
    key = T.must(variable_name.to_s[1..-1]).to_sym
    params[key] = instance_variable_get(variable_name)

    if !params[key].nil? && params[key].respond_to?(:to_h)
      params[key] = params[key].to_h
    end
  end
end