Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/enumerations/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def define_attributes_getters

self.class.send :define_method, key do |locale: I18n.locale|
case @attributes[key]
when Enumerations::Base then @attributes[key]
when String, Symbol then translate_attribute(key, locale)
else @attributes[key]
end
Expand Down
9 changes: 9 additions & 0 deletions test/value_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,13 @@ def test_string_methods_on_value

assert_equal enum.foobar.upcase, 'FOOBAR'
end

def test_enumeration_attribute_storing_another_enumeration_is_returned_as_is
enum = Class.new(Enumerations::Base) do
value :foobar, related: Role.admin
end

assert_instance_of Role, enum.foobar.related
assert_equal true, enum.foobar.related.admin?
end
end
Loading