Method: Scimitar::Resources::Base#flatten_extension_attributes
- Defined in:
- app/models/scimitar/resources/base.rb
#flatten_extension_attributes(options) ⇒ Object
Scimitar has at present a general limitation in handling schema IDs, which just involves stripping them and requiring attributes across all extension schemas to be overall unique.
This method takes an options payload for the initializer and strips out recognised schema IDs, so that the resulting attribute data matches the resource attribute map.
attributes-
Attributes to assign via initializer; typically a POST payload of attributes that has been run through Rails strong parameters for safety.
Returns a new object of the same class as options with recognised schema IDs removed.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/models/scimitar/resources/base.rb', line 53 def flatten_extension_attributes() flattened = .class.new lower_case_schema_ids = self.class.extended_schemas.map do | schema | schema.id.downcase() end .each do | key, value | path = Scimitar::Support::Utilities::path_str_to_array( self.class.extended_schemas, key ) if path.first.include?(':') && lower_case_schema_ids.include?(path.first.downcase) path.shift() end if path.empty? flattened.merge!(value) else flattened[path.join('.')] = value end end return flattened end |