Class: Trello::Schema::Attribute::CustomFieldDisplay

Inherits:
Base
  • Object
show all
Defined in:
lib/trello/schema/attribute/custom_field_display.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #options, #serializer

Instance Method Summary collapse

Methods inherited from Base

#build_pending_update_attributes, #create_only?, #default, #for_action?, #initialize, #primary_key?, #readonly?, #register, #remote_key, #update_only?

Constructor Details

This class inherits a constructor from Trello::Schema::Attribute::Base

Instance Method Details

#build_attributes(params, attributes) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/trello/schema/attribute/custom_field_display.rb', line 6

def build_attributes(params, attributes)
  attrs = attributes.with_indifferent_access
  params = params.with_indifferent_access

  value = if params.key?(:display)
            params[:display][remote_key]
          else
            params[name]
          end

  attrs[name] = serializer.deserialize(value, default)
  attrs
end

#build_payload_for_create(attributes, payload) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trello/schema/attribute/custom_field_display.rb', line 20

def build_payload_for_create(attributes, payload)
  payload ||= {}
  return payload unless for_action?(:create)
  return payload unless attributes.key?(name)

  value = attributes[name]
  return payload if value.nil?

  payload["display_#{remote_key}"] = serializer.serialize(value)
  payload
end

#build_payload_for_update(attributes, payload) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/trello/schema/attribute/custom_field_display.rb', line 32

def build_payload_for_update(attributes, payload)
  payload ||= {}
  return payload unless for_action?(:update)
  return payload unless attributes.key?(name)

  value = attributes[name]
  payload["display/#{remote_key}"] = serializer.serialize(value)
  payload
end