Class: Connectors::MongoDB::Connector
Class Method Summary
collapse
Instance Method Summary
collapse
#do_health_check!, #is_healthy?
Constructor Details
#initialize(configuration: {}) ⇒ Connector
Returns a new instance of Connector.
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/connectors/mongodb/connector.rb', line 47
def initialize(configuration: {})
super
@host = configuration.dig(:host, :value)
@database = configuration.dig(:database, :value)
@collection = configuration.dig(:collection, :value)
@user = configuration.dig(:user, :value)
@password = configuration.dig(:password, :value)
@direct_connection = configuration.dig(:direct_connection, :value)
end
|
Class Method Details
.configurable_fields ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/connectors/mongodb/connector.rb', line 24
def self.configurable_fields
{
:host => {
:label => 'Server Hostname'
},
:user => {
:label => 'Username'
},
:password => {
:label => 'Password'
},
:database => {
:label => 'Database'
},
:collection => {
:label => 'Collection'
},
:direct_connection => {
:label => 'Direct connection? (true/false)'
}
}
end
|
.display_name ⇒ Object
20
21
22
|
# File 'lib/connectors/mongodb/connector.rb', line 20
def self.display_name
'MongoDB'
end
|
.service_type ⇒ Object
16
17
18
|
# File 'lib/connectors/mongodb/connector.rb', line 16
def self.service_type
'mongodb'
end
|
Instance Method Details
#yield_documents ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/connectors/mongodb/connector.rb', line 58
def yield_documents
with_client do |client|
client[@collection].find.each do |document|
doc = document.with_indifferent_access
yield serialize(doc)
end
end
end
|