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]
Environment
Ruby version: 3.3.4
ActiveHash version: 3.3.1
Description of the issue
When using
ActiveHash::Enumin combination withActiveHash::Base, thefield_namesmethod returns duplicate field names. This occurs only whenenum_accessoris used.Steps to reproduce
Example code
Expected behavior
The field_names method should return unique field names:
Additional information
This issue does not occur when ActiveHash::Enum is included without using enum_accessor: