Module: HashSerializer::Helpers::ClassMethods
- Defined in:
- lib/hash_serializer/helpers.rb
Overview
Helper methods available on the class
Instance Method Summary collapse
-
#hash_accessor_with_prefix(hash_name, prefix, *keys) ⇒ Object
Creates ActiveRecord model methods for a Postgres JSON hash.
Instance Method Details
#hash_accessor_with_prefix(hash_name, prefix, *keys) ⇒ Object
Creates ActiveRecord model methods for a Postgres JSON hash
Example:
>> hash_accessor_with_prefix :stripe_oauth_fields, 'stripe_connect', VALID_STRIPE_OAUTH_FIELDS
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hash_serializer/helpers.rb', line 39 def hash_accessor_with_prefix(hash_name, prefix, *keys) Array(keys).flatten.each do |key| prefixed_key = "#{prefix}_#{key}" # Ex - billing_token= create_setter_methods(hash_name, prefixed_key, key) # Ex - billing_token create_getters(hash_name, prefixed_key, key) # Ex - billing_token_changed? create_changed_methods(prefixed_key) end end |