Class: Nylas::Model::ListAttributeDefinition
- Inherits:
-
Object
- Object
- Nylas::Model::ListAttributeDefinition
- Defined in:
- lib/nylas/model/list_attribute_definition.rb
Overview
Allows models to have an attribute which is a lists of another type of thing
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#read_only ⇒ Object
Returns the value of attribute read_only.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
Instance Method Summary collapse
- #cast(list) ⇒ Object
-
#initialize(type_name:, read_only:, default:) ⇒ ListAttributeDefinition
constructor
A new instance of ListAttributeDefinition.
- #serialize(list, enforce_read_only: false) ⇒ Object
- #serialize_for_api(list) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(type_name:, read_only:, default:) ⇒ ListAttributeDefinition
Returns a new instance of ListAttributeDefinition.
9 10 11 12 13 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 9 def initialize(type_name:, read_only:, default:) self.type_name = type_name self.read_only = read_only self.default = default end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
7 8 9 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 7 def default @default end |
#read_only ⇒ Object
Returns the value of attribute read_only.
7 8 9 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 7 def read_only @read_only end |
#type_name ⇒ Object
Returns the value of attribute type_name.
7 8 9 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 7 def type_name @type_name end |
Instance Method Details
#cast(list) ⇒ Object
15 16 17 18 19 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 15 def cast(list) return default if list.nil? || list.empty? list.map { |item| type.cast(item) } end |
#serialize(list, enforce_read_only: false) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 21 def serialize(list, enforce_read_only: false) list = default if list.nil? || list.empty? if enforce_read_only list.map { |item| type.serialize_for_api(item) } else list.map { |item| type.serialize(item) } end end |
#serialize_for_api(list) ⇒ Object
30 31 32 |
# File 'lib/nylas/model/list_attribute_definition.rb', line 30 def serialize_for_api(list) serialize(list, enforce_read_only: true) end |