Class: Vng::SystemField

Inherits:
Resource show all
Defined in:
lib/vng/system_field.rb

Overview

Provides methods to interact with Vonigo system fields.

Constant Summary collapse

PATH =
'/api/v1/system/objects/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, options:) ⇒ SystemField



10
11
12
13
14
# File 'lib/vng/system_field.rb', line 10

def initialize(id:, name:, options:)
  @id = id
  @name = name
  @options = options
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/system_field.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/vng/system_field.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/vng/system_field.rb', line 8

def options
  @options
end

Class Method Details

.for_system_object_id(system_object_id) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/vng/system_field.rb', line 16

def self.for_system_object_id(system_object_id)
  body = { objectID: system_object_id, method: '1' }
  data = request path: PATH, body: body

  data['Fields'].lazy.map do |field|
    options = SystemOption.for_system_field_id field['fieldID'], data['Options']
    new id: field['fieldID'], name: field['field'], options: options
  end # TODO: make this thing respond to find_by(name:)
end