Module: Familia::Features::TransientFields::ModelClassMethods
- Defined in:
- lib/familia/features/transient_fields.rb
Instance Method Summary collapse
-
#transient_field(name, as: name, **kwargs) ⇒ Object
Define a transient field that automatically wraps values in RedactedString.
-
#transient_field?(field_name) ⇒ Boolean
Check if a field is transient.
-
#transient_fields ⇒ Array<Symbol>
Returns list of transient field names defined on this class.
Instance Method Details
#transient_field(name, as: name, **kwargs) ⇒ Object
Define a transient field that automatically wraps values in RedactedString
Transient fields are not persisted to Redis/Valkey and exist only in memory. All values are automatically wrapped in RedactedString for security.
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/familia/features/transient_fields.rb', line 145 def transient_field(name, as: name, **kwargs) @transient_fields ||= [] @transient_fields << name unless @transient_fields.include?(name) # Add to field_groups if the group exists if field_groups&.key?(:transient_fields) field_groups[:transient_fields] << name end # Use the field type system for proper integration field_type = TransientFieldType.new(name, as: as, **kwargs.merge(fast_method: false)) register_field_type(field_type) end |
#transient_field?(field_name) ⇒ Boolean
Check if a field is transient
172 173 174 |
# File 'lib/familia/features/transient_fields.rb', line 172 def transient_field?(field_name) transient_fields.include?(field_name.to_sym) end |
#transient_fields ⇒ Array<Symbol>
Returns list of transient field names defined on this class
163 164 165 |
# File 'lib/familia/features/transient_fields.rb', line 163 def transient_fields @transient_fields || [] end |