Skip to content

Commit fca61c9

Browse files
authored
Fix initializing for plain String of Ruby (#509)
Fix the problem that the initialization process of a non-existent class was interrupted during the initialization of the model, when it should be set to the instance variable as is in the case of an `Array[String]` or `Array[String, nil]` type. Resolve #498
1 parent 619dc7c commit fca61c9

21 files changed

Lines changed: 25 additions & 147 deletions

generator/src/main/resources/line-bot-sdk-ruby-generator/model.pebble

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ module Line
7272
{% if model.model.vendorExtensions.get("x-selector") != null %}@{{model.model.vendorExtensions.get("x-selector").propertyName}} = "{{model.model.vendorExtensions.get("x-selector").mappingName}}"{%- endif -%}
7373
{%- for property in model.model.vars %}
7474
{% if property.isArray -%}
75+
{%- if property.items.isModel -%}
7576
@{{ property.name }} = {{ property.name }}{{ property.required ? '' : '&' }}.map do |item|
7677
if item.is_a?(Hash)
7778
Line::Bot::V2::{{ packageName | camelize }}::{{ property.complexType }}.create(**item) # steep:ignore InsufficientKeywordArguments
7879
else
7980
item
8081
end
8182
end
83+
{%- else -%}
84+
@{{ property.name }} = {{ property.name }}
85+
{%- endif -%}
8286
{%- elseif property.isModel -%}
8387
@{{ property.name }} = {{ property.name }}.is_a?(Line::Bot::V2::{{ packageName | camelize }}::{{ property.baseType }}){% if not property.required %} || {{ property.name }}.nil?{% endif %} ? {{ property.name }} : Line::Bot::V2::{{ packageName | camelize }}::{{ property.baseType }}.create(**{{ property.name }}) # steep:ignore
8488
{%- elseif model.model.vendorExtensions.get("x-selector").propertyName != property.name -%}

lib/line/bot/v2/channel_access_token/model/channel_access_token_key_ids_response.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ def initialize(
2424
**dynamic_attributes
2525
)
2626

27-
@kids = kids.map do |item|
28-
if item.is_a?(Hash)
29-
Line::Bot::V2::ChannelAccessToken::string.create(**item) # steep:ignore InsufficientKeywordArguments
30-
else
31-
item
32-
end
33-
end
27+
@kids = kids
3428

3529
dynamic_attributes.each do |key, value|
3630
self.class.attr_accessor key

lib/line/bot/v2/liff/model/add_liff_app_request.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ def initialize(
5252
@description = description
5353
@features = features.is_a?(Line::Bot::V2::Liff::LiffFeatures) || features.nil? ? features : Line::Bot::V2::Liff::LiffFeatures.create(**features) # steep:ignore
5454
@permanent_link_pattern = permanent_link_pattern
55-
@scope = scope&.map do |item|
56-
if item.is_a?(Hash)
57-
Line::Bot::V2::Liff::LiffScope.create(**item) # steep:ignore InsufficientKeywordArguments
58-
else
59-
item
60-
end
61-
end
55+
@scope = scope
6256
@bot_prompt = bot_prompt
6357

6458
dynamic_attributes.each do |key, value|

lib/line/bot/v2/liff/model/liff_app.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ def initialize(
5757
@description = description
5858
@features = features.is_a?(Line::Bot::V2::Liff::LiffFeatures) || features.nil? ? features : Line::Bot::V2::Liff::LiffFeatures.create(**features) # steep:ignore
5959
@permanent_link_pattern = permanent_link_pattern
60-
@scope = scope&.map do |item|
61-
if item.is_a?(Hash)
62-
Line::Bot::V2::Liff::LiffScope.create(**item) # steep:ignore InsufficientKeywordArguments
63-
else
64-
item
65-
end
66-
end
60+
@scope = scope
6761
@bot_prompt = bot_prompt
6862

6963
dynamic_attributes.each do |key, value|

lib/line/bot/v2/liff/model/update_liff_app_request.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ def initialize(
5252
@description = description
5353
@features = features.is_a?(Line::Bot::V2::Liff::LiffFeatures) || features.nil? ? features : Line::Bot::V2::Liff::LiffFeatures.create(**features) # steep:ignore
5454
@permanent_link_pattern = permanent_link_pattern
55-
@scope = scope&.map do |item|
56-
if item.is_a?(Hash)
57-
Line::Bot::V2::Liff::LiffScope.create(**item) # steep:ignore InsufficientKeywordArguments
58-
else
59-
item
60-
end
61-
end
55+
@scope = scope
6256
@bot_prompt = bot_prompt
6357

6458
dynamic_attributes.each do |key, value|

lib/line/bot/v2/messaging_api/model/app_type_demographic_filter.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def initialize(
2828
)
2929
@type = "appType"
3030

31-
@one_of = one_of&.map do |item|
32-
if item.is_a?(Hash)
33-
Line::Bot::V2::MessagingApi::AppTypeDemographic.create(**item) # steep:ignore InsufficientKeywordArguments
34-
else
35-
item
36-
end
37-
end
31+
@one_of = one_of
3832

3933
dynamic_attributes.each do |key, value|
4034
self.class.attr_accessor key

lib/line/bot/v2/messaging_api/model/area_demographic_filter.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def initialize(
2828
)
2929
@type = "area"
3030

31-
@one_of = one_of&.map do |item|
32-
if item.is_a?(Hash)
33-
Line::Bot::V2::MessagingApi::AreaDemographic.create(**item) # steep:ignore InsufficientKeywordArguments
34-
else
35-
item
36-
end
37-
end
31+
@one_of = one_of
3832

3933
dynamic_attributes.each do |key, value|
4034
self.class.attr_accessor key

lib/line/bot/v2/messaging_api/model/gender_demographic_filter.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def initialize(
2828
)
2929
@type = "gender"
3030

31-
@one_of = one_of&.map do |item|
32-
if item.is_a?(Hash)
33-
Line::Bot::V2::MessagingApi::GenderDemographic.create(**item) # steep:ignore InsufficientKeywordArguments
34-
else
35-
item
36-
end
37-
end
31+
@one_of = one_of
3832

3933
dynamic_attributes.each do |key, value|
4034
self.class.attr_accessor key

lib/line/bot/v2/messaging_api/model/get_aggregation_unit_name_list_response.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def initialize(
2828
**dynamic_attributes
2929
)
3030

31-
@custom_aggregation_units = custom_aggregation_units.map do |item|
32-
if item.is_a?(Hash)
33-
Line::Bot::V2::MessagingApi::string.create(**item) # steep:ignore InsufficientKeywordArguments
34-
else
35-
item
36-
end
37-
end
31+
@custom_aggregation_units = custom_aggregation_units
3832
@_next = _next
3933

4034
dynamic_attributes.each do |key, value|

lib/line/bot/v2/messaging_api/model/get_followers_response.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ def initialize(
2828
**dynamic_attributes
2929
)
3030

31-
@user_ids = user_ids.map do |item|
32-
if item.is_a?(Hash)
33-
Line::Bot::V2::MessagingApi::string.create(**item) # steep:ignore InsufficientKeywordArguments
34-
else
35-
item
36-
end
37-
end
31+
@user_ids = user_ids
3832
@_next = _next
3933

4034
dynamic_attributes.each do |key, value|

0 commit comments

Comments
 (0)