From ea4f4ae30dabaacf2e04398d680abf843b1c163b Mon Sep 17 00:00:00 2001 From: Yuliya Glushchenko Date: Tue, 20 Jul 2021 18:12:03 +0300 Subject: [PATCH 1/2] Add downcase for name-key in amo_property method, add condition for :method_name in merge_custom_fields --- lib/amorail/entity.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/amorail/entity.rb b/lib/amorail/entity.rb index 8e1f702..25bf5b7 100644 --- a/lib/amorail/entity.rb +++ b/lib/amorail/entity.rb @@ -33,7 +33,7 @@ def amo_field(*vars, **hargs) end def amo_property(name, options = {}) - properties[name] = options + properties[name.downcase] = options attr_accessor(options.fetch(:method_name, name)) end @@ -92,6 +92,7 @@ def merge_custom_fields(fields) fname = custom_field_name(f) next if fname.nil? + fname = self.class.properties.fetch(fname.downcase, {})[:method_name] || fname fname = "#{fname.downcase}=" fval = f.fetch('values').first.fetch('value') send(fname, fval) if respond_to?(fname) From a98be1790bac77acba8039a58581a830200a5723 Mon Sep 17 00:00:00 2001 From: Yuliya Glushchenko Date: Wed, 21 Jul 2021 13:30:12 +0300 Subject: [PATCH 2/2] Remove duplicate calling method_name on custom fields --- lib/amorail/entity.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/amorail/entity.rb b/lib/amorail/entity.rb index 25bf5b7..68c3e06 100644 --- a/lib/amorail/entity.rb +++ b/lib/amorail/entity.rb @@ -92,7 +92,6 @@ def merge_custom_fields(fields) fname = custom_field_name(f) next if fname.nil? - fname = self.class.properties.fetch(fname.downcase, {})[:method_name] || fname fname = "#{fname.downcase}=" fval = f.fetch('values').first.fetch('value') send(fname, fval) if respond_to?(fname)