Class: Render::ArrayAttribute
- Defined in:
- lib/render/attributes/array_attribute.rb
Constant Summary collapse
- FAUX_DATA_UPPER_LIMIT =
5.freeze
Constants inherited from Attribute
Render::Attribute::SCHEMA_IDENTIFIERS
Instance Attribute Summary collapse
-
#archetype ⇒ Object
Returns the value of attribute archetype.
Attributes inherited from Attribute
#enums, #format, #name, #required, #schema, #type
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ArrayAttribute
constructor
A new instance of ArrayAttribute.
- #serialize(explicit_values = nil) ⇒ Object
Methods inherited from Attribute
#bias_type, #default_value, #nested_schema?
Constructor Details
#initialize(options = {}) ⇒ ArrayAttribute
Returns a new instance of ArrayAttribute.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/render/attributes/array_attribute.rb', line 9 def initialize( = {}) super self.name = .fetch(:title, :render_array_attribute_untitled).to_sym self.required = .fetch(:required, nil) = .fetch(:items) process_type!() if .keys.include?(:properties) self.schema = Schema.new() else self.archetype = true end end |
Instance Attribute Details
#archetype ⇒ Object
Returns the value of attribute archetype.
7 8 9 |
# File 'lib/render/attributes/array_attribute.rb', line 7 def archetype @archetype end |
Instance Method Details
#serialize(explicit_values = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/render/attributes/array_attribute.rb', line 24 def serialize(explicit_values = nil) explicit_values = faux_array_data if (Render.live == false && explicit_values.nil?) if archetype explicit_values.collect do |value| value || default_value end else explicit_values.collect do |value| schema.serialize!(value) end end end |