Skip to content

Commit

Permalink
docs: Add comment for rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
hatsu38 committed Jul 4, 2024
1 parent 0540d03 commit 45adef8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/active_hash/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ def field_names
@field_names ||= []
end

#
# Useful for CSV integration needing column names as strings.
#
# @return [Array<String>] An array of column names as strings.
#
# @example Usage
# class Country < ActiveHash::Base
# fields :name, :code
# end
#
# Country.column_names
# # => ["id", "name", "code"]
#
def column_names
@column_names ||= field_names.map(&:name)
end
Expand Down

0 comments on commit 45adef8

Please sign in to comment.