From 929823cd4c1a62531395ef002d255c240607d936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gro=C3=9F?= Date: Thu, 19 Jul 2018 17:19:06 +0200 Subject: [PATCH 1/3] adding test to support hash indexing with instances of flexirest --- .ruby-version | 1 + .travis.yml | 1 + lib/flexirest/base_without_validation.rb | 5 ----- spec/lib/ruby_core_spec.rb | 12 ++++++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .ruby-version create mode 100644 spec/lib/ruby_core_spec.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..197c4d5 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.4.0 diff --git a/.travis.yml b/.travis.yml index 6b5689b..a541dd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: ruby rvm: + - 2.5.0 - 2.4.0 - 2.3.0 - 2.2.2 diff --git a/lib/flexirest/base_without_validation.rb b/lib/flexirest/base_without_validation.rb index 3d39252..b8992ba 100644 --- a/lib/flexirest/base_without_validation.rb +++ b/lib/flexirest/base_without_validation.rb @@ -12,11 +12,6 @@ class BaseWithoutValidation attr_accessor :_etag attr_accessor :_headers - instance_methods.each do |m| - next unless %w{display presence load require hash untrust trust freeze method enable_warnings with_warnings suppress capture silence quietly debugger breakpoint}.map(&:to_sym).include? m - undef_method m - end - def initialize(attrs={}) @attributes = {} @dirty_attributes = Hash.new diff --git a/spec/lib/ruby_core_spec.rb b/spec/lib/ruby_core_spec.rb new file mode 100644 index 0000000..f596860 --- /dev/null +++ b/spec/lib/ruby_core_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +class EmptyExample < Flexirest::BaseWithoutValidation + whiny_missing true +end + +describe Flexirest::BaseWithoutValidation do + it 'should support hash resolving' do + h = {} + expect{ h[EmptyExample.new] = 'not important' }.to_not raise_error + end +end \ No newline at end of file From 2a1a642a943003d133a5b58824a49e84a041be2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gro=C3=9F?= Date: Thu, 19 Jul 2018 17:27:26 +0200 Subject: [PATCH 2/3] do not add local dev environment --- .ruby-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 197c4d5..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.0 From f7d57297af4f769dbb57fbaa9a036a255c4f8966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gro=C3=9F?= Date: Tue, 31 Jul 2018 15:58:12 +0200 Subject: [PATCH 3/3] keep the hash method, because it is required in ruby to use a class instance as a hash-key --- lib/flexirest/base_without_validation.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/flexirest/base_without_validation.rb b/lib/flexirest/base_without_validation.rb index b8992ba..6633fdc 100644 --- a/lib/flexirest/base_without_validation.rb +++ b/lib/flexirest/base_without_validation.rb @@ -12,6 +12,11 @@ class BaseWithoutValidation attr_accessor :_etag attr_accessor :_headers + instance_methods.each do |m| + next unless %w{display presence load require untrust trust freeze method enable_warnings with_warnings suppress capture silence quietly debugger breakpoint}.map(&:to_sym).include? m + undef_method m + end + def initialize(attrs={}) @attributes = {} @dirty_attributes = Hash.new