Class: Nova::API::Utils::BaseStruct

Inherits:
Dry::Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/nova/api/utils/base_struct.rb

Constant Summary collapse

DATE_REGEX =
/\A\d{4}-\d{2}-\d{2}\z/

Instance Method Summary collapse

Instance Method Details

#allowed_attributesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nova/api/utils/base_struct.rb', line 14

def allowed_attributes
  return attributes unless self.class.const_defined?('ALLOWED_ATTRIBUTES')

  data = {}

  self.class.const_get('ALLOWED_ATTRIBUTES').each do |key|
    next unless attributes.keys.include? key

    value = attributes[key]

    data[key.to_sym] = extract_value(key, value)
  end

  data
end