Skip to content

Commit

Permalink
Merge pull request #58 from infinum/fix/method-missing-instantiates-n…
Browse files Browse the repository at this point in the history
…ew-base

Prevent method_missing to instantiates new Enumerations::Base
  • Loading branch information
PetarCurkovic authored Feb 2, 2022
2 parents 692141f + e6b618c commit d7a8caa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [v2.5.3](https://github.com/infinum/enumerations/tree/v2.5.3) (2022-02-02)
[Full Changelog](https://github.com/infinum/enumerations/compare/v2.5.2...v2.5.3)

**Fixed bugs:**

- Prevent `method_missing` instantiates new instance of `Enumerations::Base`; returns `String` instead

**Merged pull requests:**

- Prevent method_missing to instantiates new Enumerations::Base [\#58](https://github.com/infinum/enumerations/pull/58) ([PetarCurkovic](https://github.com/PetarCurkovic))

## [v2.5.2](https://github.com/infinum/enumerations/tree/v2.5.2) (2022-01-27)
[Full Changelog](https://github.com/infinum/enumerations/compare/v2.5.1...v2.5.2)

Expand Down
6 changes: 6 additions & 0 deletions lib/enumerations/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,11 @@ def initialize(symbol, attributes)

create_instance_methods
end

private

def chars(string)
string
end
end
end
2 changes: 1 addition & 1 deletion lib/enumerations/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Enumerations
VERSION = '2.5.2'.freeze
VERSION = '2.5.3'.freeze
end
8 changes: 8 additions & 0 deletions test/value_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,12 @@ def test_enumeration_does_not_respond_to_nonexistent_attribute

assert_equal enum.foobar.respond_to?(:name), false
end

def test_string_methods_on_value
enum = Class.new(Enumerations::Base) do
value :foobar
end

assert_equal enum.foobar.upcase, 'FOOBAR'
end
end

0 comments on commit d7a8caa

Please sign in to comment.