From 6d8b1ea9e9b008b544a7fa3bc52fbd828adcd3b5 Mon Sep 17 00:00:00 2001 From: Brian Durand Date: Mon, 1 May 2023 12:34:03 -0700 Subject: [PATCH] freeze values returned by helper methods. --- CHANGELOG.md | 4 ++++ VERSION | 2 +- lib/support_table_data.rb | 2 +- spec/support_table_data_spec.rb | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5563753..4496cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.1.1 + +- Freeze values returned from helper methods. + ## 1.1.0 ### Added diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/lib/support_table_data.rb b/lib/support_table_data.rb index 63445c0..1b68e0f 100644 --- a/lib/support_table_data.rb +++ b/lib/support_table_data.rb @@ -225,7 +225,7 @@ def define_support_table_instance_attribute_helper(method_name, attribute_value) class_eval <<~RUBY, __FILE__, __LINE__ + 1 def self.#{method_name} - #{attribute_value.inspect} + #{attribute_value.inspect}.freeze end RUBY end diff --git a/spec/support_table_data_spec.rb b/spec/support_table_data_spec.rb index ebec39f..30ca36b 100644 --- a/spec/support_table_data_spec.rb +++ b/spec/support_table_data_spec.rb @@ -153,6 +153,11 @@ expect(Group.support_table_attribute_helpers).to match_array ["group_id", "name"] expect(Color.support_table_attribute_helpers).to match_array [] end + + it "returns frozen values" do + expect(Group.primary_group_id).to be_frozen + expect(Group.primary_name).to be_frozen + end end describe "protected_instance?" do