Sha256: 8dffec65eb5d04001b3e64c232ca3aeacaca4c3ae4430678d6796926bb23f032
Contents?: true
Size: 760 Bytes
Versions: 138
Compression:
Stored size: 760 Bytes
Contents
require 'active_support/concern' require 'active_support/core_ext/class/attribute' module ActiveRecord module ReadonlyAttributes extend ActiveSupport::Concern included do class_attribute :_attr_readonly, :instance_writer => false self._attr_readonly = [] end module ClassMethods # Attributes listed as readonly will be used to create a new record but update operations will # ignore these fields. def attr_readonly(*attributes) self._attr_readonly = Set.new(attributes.map { |a| a.to_s }) + (self._attr_readonly || []) end # Returns an array of all the attributes that have been specified as readonly. def readonly_attributes self._attr_readonly end end end end
Version data entries
138 entries across 107 versions & 14 rubygems