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

Version Path
knitkit-2.1.15 app/models/document.rb
knitkit-2.1.14 app/models/document.rb
knitkit-2.1.13 app/models/document.rb
knitkit-2.1.12 app/models/document.rb
knitkit-2.1.11 app/models/document.rb
knitkit-2.1.10 app/models/document.rb
knitkit-2.1.9 app/models/document.rb
knitkit-2.1.8 app/models/document.rb
knitkit-2.1.7 app/models/document.rb
knitkit-2.1.6 app/models/document.rb
knitkit-2.1.5 app/models/document.rb
knitkit-2.1.4 app/models/document.rb
knitkit-2.1.3 app/models/document.rb
knitkit-2.1.2 app/models/document.rb
knitkit-2.1.1 app/models/document.rb
knitkit-2.1.0 app/models/document.rb