Class: CDP::Builder
- Inherits:
-
Object
show all
- Defined in:
- lib/cdp/builder.rb
Instance Method Summary
collapse
Constructor Details
#initialize(tenant_id:, schema:) ⇒ Builder
Returns a new instance of Builder.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/cdp/builder.rb', line 5
def initialize(tenant_id:, schema:)
@tenant_id = tenant_id
filtered_schema = schema.to_hash
filtered_schema[:entity_types].each do |entity_type|
entity_type[:field_types] = entity_type[:field_types].each_with_object({}) do |field_type, memo|
memo[field_type[:name]] = field_type.except(:custom_data)
end
end
filtered_schema[:event_types].each do |event_type|
event_type[:field_types] = event_type[:field_types].each_with_object({}) do |field_type, memo|
memo[field_type[:name]] = field_type.except(:custom_data)
end
end
@schema = filtered_schema
@builders = generate_builders_map
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_args) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/cdp/builder.rb', line 36
def method_missing(method_name, *_args)
method_name_str = method_name.to_s.upcase
return @builders[method_name_str] if @builders.key?(method_name_str)
super
end
|
Instance Method Details
#create_transaction ⇒ Object
29
30
31
32
33
34
|
# File 'lib/cdp/builder.rb', line 29
def create_transaction
CDP::Transaction.new(
tenant_id: @tenant_id,
commands: []
)
end
|
#if_created(source) ⇒ Object
25
26
27
|
# File 'lib/cdp/builder.rb', line 25
def if_created(source)
Builders::AfterCreated.new(self, source)
end
|