From 45adef80b122fd152b962213d6f9fb4ca234fec3 Mon Sep 17 00:00:00 2001 From: hatsu38 Date: Fri, 5 Jul 2024 00:02:25 +0900 Subject: [PATCH] docs: Add comment for rdoc --- lib/active_hash/base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/active_hash/base.rb b/lib/active_hash/base.rb index 44fa111..f68aa80 100644 --- a/lib/active_hash/base.rb +++ b/lib/active_hash/base.rb @@ -50,6 +50,19 @@ def field_names @field_names ||= [] end + # + # Useful for CSV integration needing column names as strings. + # + # @return [Array] 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