Skip to content

Commit

Permalink
expose attribute helper names
Browse files Browse the repository at this point in the history
  • Loading branch information
bdurand committed Apr 27, 2023
1 parent 0270bdf commit cc5d68b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/support_table_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ def named_instance_attribute_helpers(*attributes)
define_support_table_named_instances
end

# Get the names of any named instance attribute helpers that have been defined
# with `named_instance_attribute_helpers`.
#
# @return [Array<String>] List of attribute names.
def support_table_attribute_helpers
@support_table_attribute_helpers ||= {}
@support_table_attribute_helpers.keys
end

# Get the data for the support table from the data files.
#
# @return [Array<Hash>] List of attributes for all records in the data files.
Expand Down
5 changes: 5 additions & 0 deletions spec/support_table_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
expect(Group.secondary_name).to eq "secondary"
expect(Group.gray_name).to eq "gray"
end

it "can get a list of the defined attribute helpers" do
expect(Group.support_table_attribute_helpers).to match_array ["group_id", "name"]
expect(Color.support_table_attribute_helpers).to match_array []
end
end

describe "protected_instance?" do
Expand Down

0 comments on commit cc5d68b

Please sign in to comment.