Module: Calendly::ModelUtils

Overview

Calendly model utility.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

UUID_FORMAT =

UUID’s format is ASCII. refs to official release note of October 2021.

'[[:ascii:]]+'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



76
77
78
# File 'lib/calendly/models/model_utils.rb', line 76

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

Instance Method Details

#clientCalendly::Client

Returns api client.

Returns:

Raises:

Since:

  • 0.1.0



25
26
27
28
29
# File 'lib/calendly/models/model_utils.rb', line 25

def client
  raise Error.new('@client is not ready.') if !@client || !@client.is_a?(Client)

  @client
end

#idString

Alias of uuid.

Returns:

  • (String)

Raises:

Since:

  • 0.1.0



37
38
39
40
41
# File 'lib/calendly/models/model_utils.rb', line 37

def id
  raise Error.new('uuid is not defined.') unless defined? uuid

  uuid
end

#initialize(attrs = nil, client = nil) ⇒ Object

Parameters:

  • attrs (Hash) (defaults to: nil)

    the attributes of the model.

  • the (Calendly::Client)

    api client.



14
15
16
17
# File 'lib/calendly/models/model_utils.rb', line 14

def initialize(attrs = nil, client = nil)
  @client = client
  set_attributes attrs
end

#inspectString

Self object description human readable in CLI.

Returns:

  • (String)

Since:

  • 0.0.1



48
49
50
51
52
53
54
55
56
57
# File 'lib/calendly/models/model_utils.rb', line 48

def inspect
  att_info = []
  inspect_attributes.each do |att|
    next unless respond_to? att

    att_info << "#{att}=#{send(att).inspect}"
  end
  att_info << '..'
  "\#<#{self.class}:#{object_id} #{att_info.join(', ')}>"
end