Sha256: 5186a91d256fd4fa1aea0184741f4ebc9390843052196cdac4e6bfb396c4a816
Contents?: true
Size: 693 Bytes
Versions: 16
Compression:
Stored size: 693 Bytes
Contents
class Document < ActiveRecord::Base attr_protected :created_at, :updated_at DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX = 'dyn_' has_dynamic_attributes :dynamic_attribute_prefix => DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX, :destroy_dynamic_attribute_for_nil => false has_file_assets belongs_to :document_record, :polymorphic => true belongs_to :document_type class << self def add_dyn_prefix(field) "#{DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX}#{field}" end def remove_dyn_prefix(field) field.gsub(DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX, '') end end def set_dyn_attribute(field, value) self.send("#{Document.add_dyn_prefix(field)}=", value) end end
Version data entries
16 entries across 16 versions & 1 rubygems