Skip to content

Commit dee41d1

Browse files
committed
Remove to_h
1 parent 107f2ba commit dee41d1

10 files changed

Lines changed: 8 additions & 72 deletions

File tree

lib/mailtrap/contact.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,5 @@ def initialize(options)
2929
def newly_created?
3030
@action != 'updated'
3131
end
32-
33-
# @return [Hash] The contact attributes as a hash
34-
def to_h
35-
super.compact
36-
end
3732
end
3833
end

lib/mailtrap/contact_field.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ module Mailtrap
99
# Allowed values: text, integer, float, boolean, date
1010
# @attr_reader merge_tag [String] Personalize your campaigns by adding a merge tag.
1111
# This field will be replaced with unique contact details for each recipient (max 80 characters)
12-
ContactField = Struct.new(:id, :name, :data_type, :merge_tag, keyword_init: true) do
13-
# @return [Hash] The contact field attributes as a hash
14-
def to_h
15-
super.compact
16-
end
17-
end
12+
ContactField = Struct.new(:id, :name, :data_type, :merge_tag, keyword_init: true)
1813
end

lib/mailtrap/contact_import.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,5 @@ module Mailtrap
1414
:updated_contacts_count,
1515
:contacts_over_limit_count,
1616
keyword_init: true
17-
) do
18-
# @return [Hash] The contact attributes as a hash
19-
def to_h
20-
super.compact
21-
end
22-
end
17+
)
2318
end

lib/mailtrap/contact_list.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,5 @@ module Mailtrap
55
# @see https://api-docs.mailtrap.io/docs/mailtrap-api-docs/6ec7a37234af2-contact-list
66
# @attr_reader id [Integer] The contact list ID
77
# @attr_reader name [String] The name of the contact list
8-
ContactList = Struct.new(:id, :name, keyword_init: true) do
9-
# @return [Hash] The contact list attributes as a hash
10-
def to_h
11-
super.compact
12-
end
13-
end
8+
ContactList = Struct.new(:id, :name, keyword_init: true)
149
end

lib/mailtrap/email_template.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,5 @@ module Mailtrap
2626
:created_at,
2727
:updated_at,
2828
keyword_init: true
29-
) do
30-
# @return [Hash] The template attributes as a hash
31-
def to_h
32-
super.compact
33-
end
34-
end
29+
)
3530
end

lib/mailtrap/inbox.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,5 @@ module Mailtrap
5353
:max_message_size,
5454
:permissions,
5555
keyword_init: true
56-
) do
57-
# @return [Hash] The inbox attributes as a hash
58-
def to_h
59-
super.compact
60-
end
61-
end
56+
)
6257
end

lib/mailtrap/project.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,5 @@ module Mailtrap
1616
:inboxes,
1717
:permissions,
1818
keyword_init: true
19-
) do
20-
# @return [Hash] The Project attributes as a hash
21-
def to_h
22-
super.compact
23-
end
24-
end
19+
)
2520
end

lib/mailtrap/suppression.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,5 @@ module Mailtrap
3737
:message_sender_email,
3838
:message_subject,
3939
keyword_init: true
40-
) do
41-
# @return [Hash] The suppression attributes as a hash
42-
def to_h
43-
super.compact
44-
end
45-
end
40+
)
4641
end

spec/mailtrap/contact_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
})
4747
end
4848

49-
it 'omits nil values' do
50-
attributes[:fields] = nil
51-
expect(described_class.new(attributes).to_h).not_to have_key(:fields)
52-
end
53-
5449
it 'returns without action' do
5550
expect(contact.to_h).not_to have_key(:action)
5651
end

spec/mailtrap/project_spec.rb

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
end
3333

3434
it 'creates a project with all attributes' do
35-
expect(project).to have_attributes(
35+
expect(project).to match_struct(
3636
id: '123456',
3737
name: 'My Project',
3838
share_links: [
@@ -116,24 +116,5 @@
116116
}
117117
)
118118
end
119-
120-
context 'when some attributes are nil' do
121-
let(:project) do
122-
described_class.new(
123-
id: '123456',
124-
name: 'My Project',
125-
share_links: nil,
126-
inboxes: nil,
127-
permissions: nil
128-
)
129-
end
130-
131-
it 'returns a hash with only non-nil attributes' do
132-
expect(hash).to eq(
133-
id: '123456',
134-
name: 'My Project'
135-
)
136-
end
137-
end
138119
end
139120
end

0 commit comments

Comments
 (0)