Class: Trello::CustomFieldOption

Inherits:
BasicData show all
Defined in:
lib/trello/custom_field_option.rb

Overview

A custom field option contains the individual items in a custom field dropdown menu.

Instance Attribute Summary collapse

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicData

#==, #attributes, client, #collection_name, create, #element_name, #hash, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attrs, #save, save, #schema, schema, #update!, #update_fields

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#colorString

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trello/custom_field_option.rb', line 14

class CustomFieldOption < BasicData

  schema do
    # Readonly
    attribute :id, remote_key: '_id', readonly: true, primary_key: true
    attribute :custom_field_id, remote_key: 'idCustomField', readonly: true

    # Writable but for create only
    attribute :value, create_only: true
    attribute :color, create_only: true
    attribute :position, remote_key: 'pos', create_only: true
  end

  validates_presence_of :id, :value

  def self.find(id, params = {})
    params = params.with_indifferent_access
    custom_field_id = params.delete(:custom_field_id)
    return if custom_field_id.nil?

    from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
  end

  def delete
    client.delete(element_path)
  end

  def collection_path
    "/customFields/#{custom_field_id}/options"
  end

  def element_path
    "/customFields/#{custom_field_id}/options/#{id}"
  end
end

#custom_field_idString (readonly)

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trello/custom_field_option.rb', line 14

class CustomFieldOption < BasicData

  schema do
    # Readonly
    attribute :id, remote_key: '_id', readonly: true, primary_key: true
    attribute :custom_field_id, remote_key: 'idCustomField', readonly: true

    # Writable but for create only
    attribute :value, create_only: true
    attribute :color, create_only: true
    attribute :position, remote_key: 'pos', create_only: true
  end

  validates_presence_of :id, :value

  def self.find(id, params = {})
    params = params.with_indifferent_access
    custom_field_id = params.delete(:custom_field_id)
    return if custom_field_id.nil?

    from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
  end

  def delete
    client.delete(element_path)
  end

  def collection_path
    "/customFields/#{custom_field_id}/options"
  end

  def element_path
    "/customFields/#{custom_field_id}/options/#{id}"
  end
end

#idString (readonly)

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trello/custom_field_option.rb', line 14

class CustomFieldOption < BasicData

  schema do
    # Readonly
    attribute :id, remote_key: '_id', readonly: true, primary_key: true
    attribute :custom_field_id, remote_key: 'idCustomField', readonly: true

    # Writable but for create only
    attribute :value, create_only: true
    attribute :color, create_only: true
    attribute :position, remote_key: 'pos', create_only: true
  end

  validates_presence_of :id, :value

  def self.find(id, params = {})
    params = params.with_indifferent_access
    custom_field_id = params.delete(:custom_field_id)
    return if custom_field_id.nil?

    from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
  end

  def delete
    client.delete(element_path)
  end

  def collection_path
    "/customFields/#{custom_field_id}/options"
  end

  def element_path
    "/customFields/#{custom_field_id}/options/#{id}"
  end
end

#positionFloat

Returns:

  • (Float)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trello/custom_field_option.rb', line 14

class CustomFieldOption < BasicData

  schema do
    # Readonly
    attribute :id, remote_key: '_id', readonly: true, primary_key: true
    attribute :custom_field_id, remote_key: 'idCustomField', readonly: true

    # Writable but for create only
    attribute :value, create_only: true
    attribute :color, create_only: true
    attribute :position, remote_key: 'pos', create_only: true
  end

  validates_presence_of :id, :value

  def self.find(id, params = {})
    params = params.with_indifferent_access
    custom_field_id = params.delete(:custom_field_id)
    return if custom_field_id.nil?

    from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
  end

  def delete
    client.delete(element_path)
  end

  def collection_path
    "/customFields/#{custom_field_id}/options"
  end

  def element_path
    "/customFields/#{custom_field_id}/options/#{id}"
  end
end

#valueHash

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trello/custom_field_option.rb', line 14

class CustomFieldOption < BasicData

  schema do
    # Readonly
    attribute :id, remote_key: '_id', readonly: true, primary_key: true
    attribute :custom_field_id, remote_key: 'idCustomField', readonly: true

    # Writable but for create only
    attribute :value, create_only: true
    attribute :color, create_only: true
    attribute :position, remote_key: 'pos', create_only: true
  end

  validates_presence_of :id, :value

  def self.find(id, params = {})
    params = params.with_indifferent_access
    custom_field_id = params.delete(:custom_field_id)
    return if custom_field_id.nil?

    from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
  end

  def delete
    client.delete(element_path)
  end

  def collection_path
    "/customFields/#{custom_field_id}/options"
  end

  def element_path
    "/customFields/#{custom_field_id}/options/#{id}"
  end
end

Class Method Details

.find(id, params = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/trello/custom_field_option.rb', line 29

def self.find(id, params = {})
  params = params.with_indifferent_access
  custom_field_id = params.delete(:custom_field_id)
  return if custom_field_id.nil?

  from_response client.get("/customFields/#{custom_field_id}/options/#{id}")
end

Instance Method Details

#collection_pathObject



41
42
43
# File 'lib/trello/custom_field_option.rb', line 41

def collection_path
  "/customFields/#{custom_field_id}/options"
end

#deleteObject



37
38
39
# File 'lib/trello/custom_field_option.rb', line 37

def delete
  client.delete(element_path)
end

#element_pathObject



45
46
47
# File 'lib/trello/custom_field_option.rb', line 45

def element_path
  "/customFields/#{custom_field_id}/options/#{id}"
end