Module: Nylas::Model::Attributable

Overview

Allows defining of typecastable attributes on a model

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object



7
8
9
# File 'lib/nylas/model/attributable.rb', line 7

def self.included(model)
  model.extend(ClassMethods)
end

Instance Method Details

#attributesObject



15
16
17
# File 'lib/nylas/model/attributable.rb', line 15

def attributes
  @attributes ||= Attributes.new(self.class.attribute_definitions)
end

#initialize(**initial_data) ⇒ Object



11
12
13
# File 'lib/nylas/model/attributable.rb', line 11

def initialize(**initial_data)
  assign(**initial_data)
end

#to_h(enforce_read_only: false) ⇒ Hash

Returns Representation of the model with values serialized into primitives based on their Type.

Returns:

  • (Hash)

    Representation of the model with values serialized into primitives based on their Type



20
21
22
# File 'lib/nylas/model/attributable.rb', line 20

def to_h(enforce_read_only: false)
  attributes.to_h(enforce_read_only: enforce_read_only)
end