Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 27 lines (22 sloc) 0.76 kB
ceb33f8 @jonleighton Split out most of the AR::Base code into separate modules :cake:
jonleighton authored
1 require 'active_support/concern'
2 require 'active_support/core_ext/class/attribute'
3
4 module ActiveRecord
5 module ReadonlyAttributes
6 extend ActiveSupport::Concern
7
8 included do
9 class_attribute :_attr_readonly, :instance_writer => false
10 self._attr_readonly = []
11 end
12
13 module ClassMethods
14 # Attributes listed as readonly will be used to create a new record but update operations will
15 # ignore these fields.
16 def attr_readonly(*attributes)
17 self._attr_readonly = Set.new(attributes.map { |a| a.to_s }) + (self._attr_readonly || [])
18 end
19
20 # Returns an array of all the attributes that have been specified as readonly.
21 def readonly_attributes
22 self._attr_readonly
23 end
24 end
25 end
26 end
Something went wrong with that request. Please try again.