Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/hubspot/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ def batch_update(contacts, opts = {})
end
end

def [](name)
return @changes[name] if changes.key? name

name_property = @properties[name]

name_property.is_a?(Hash) ? name_property['value'] : name_property
end

def name
[firstname, lastname].compact.join(' ')
end
Expand Down
8 changes: 4 additions & 4 deletions lib/hubspot/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ def add_accessors(keys)
singleton_class.instance_eval do
keys.each do |k|
# Define a getter
define_method(k) { @changes[k.to_sym] || @properties.dig(k, 'value') }
define_method(k) { self[k] }
Comment thread
ur5us marked this conversation as resolved.

# Define a setter
define_method("#{k}=") do |v|
@changes[k.to_sym] = v
@changes[k] = v
end
end
end
Expand All @@ -247,9 +247,9 @@ def method_missing(method_name, *arguments, &block)
add_accessors([attr])

# Call the new setter
return send(method_name, arguments[0])
send(method_name, arguments[0])
elsif @properties.key?(method_name)
return @properties[method_name]['value']
self[method_name]
else
super
end
Expand Down