Class: YandexTracker::Objects::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_tracker/objects/base.rb

Overview

Objects::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data, context = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/yandex_tracker/objects/base.rb', line 11

def initialize(client, data, context = {})
  @client = client
  @data = data
  @context = context
  refresh_from(data)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



22
23
24
25
26
27
# File 'lib/yandex_tracker/objects/base.rb', line 22

def method_missing(name, *args)
  key = name.to_s
  return wrap_value(data[key]) if data.key?(key)

  super
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/yandex_tracker/objects/base.rb', line 9

def client
  @client
end

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/yandex_tracker/objects/base.rb', line 9

def context
  @context
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/yandex_tracker/objects/base.rb', line 9

def data
  @data
end

Instance Method Details

#expandObject

fetch full object from .self



34
35
36
37
38
39
# File 'lib/yandex_tracker/objects/base.rb', line 34

def expand
  return self unless data["self"]

  response = client.conn.get(data["self"]).body
  refresh_from(response)
end

#idObject



18
19
20
# File 'lib/yandex_tracker/objects/base.rb', line 18

def id
  data["id"]
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/yandex_tracker/objects/base.rb', line 29

def respond_to_missing?(name, include_private = false)
  data.key?(name.to_s) || super
end