-
Notifications
You must be signed in to change notification settings - Fork 190
Open
Description
Environment
Ruby version: 3.3.4
ActiveHash version: 3.3.1
Description of the issue
When using ActiveHash::Enum in combination with ActiveHash::Base, the field_names method returns duplicate field names. This occurs only when enum_accessor is used.
Steps to reproduce
- Create an ActiveHash::Base class with some data
- Include ActiveHash::Enum
- Use enum_accessor
- Call .field_names on the class
Example code
class Sport < ActiveHash::Base
self.data = [
{
key: "tennis",
category: "ball",
},
{
key: "soccer",
category: "ball",
},
]
include ActiveHash::Enum
enum_accessor :key
end
Sport.field_names
# => [:key, :category, :key, :category]Expected behavior
The field_names method should return unique field names:
Sport.field_names
# => [:key, :category]Additional information
This issue does not occur when ActiveHash::Enum is included without using enum_accessor:
class Sport < ActiveHash::Base
self.data = [
{
key: "tennis",
category: "ball",
},
{
key: "soccer",
category: "ball",
},
]
include ActiveHash::Enum
end
Sport.field_names
# => [:key, :category]Metadata
Metadata
Assignees
Labels
No labels