Class: Canvas::ExpandAttributes
- Inherits:
-
Object
- Object
- Canvas::ExpandAttributes
- Defined in:
- lib/canvas/services/expand_attributes.rb
Overview
:documented: This service will convert the attributes from a hash, as they are defined in the front matter, into an array of hashes that the Validator::SchemaAttribute class expects. e.g. the following front matter:
my_title:
type: string
my_color:
type: color
will get converted to:
[
{
"name" => "my_title",
"type" => "string"
},
{
"name" => "my_color",
"type" => "color"
}
]
Class Method Summary collapse
-
.call(attributes_hash) ⇒ Array<Hash>
Array of hashes that represent each attribute.
Class Method Details
.call(attributes_hash) ⇒ Array<Hash>
Returns array of hashes that represent each attribute.
31 32 33 34 35 36 37 38 |
# File 'lib/canvas/services/expand_attributes.rb', line 31 def call(attributes_hash) return [] if attributes_hash.nil? return attributes_hash if attributes_hash.is_a?(Array) attributes_hash.each_with_object([]) do |(name, attribute_hash), attrs| attrs << attribute_hash.merge("name" => name) end end |