Class: Property::Column
- Inherits:
-
ActiveRecord::ConnectionAdapters::Column
- Object
- ActiveRecord::ConnectionAdapters::Column
- Property::Column
- Defined in:
- lib/property/column.rb
Overview
The Column class is used to hold information about a Property declaration, such as name, type and options. It is also used to typecast from strings to the proper type (date, integer, float, etc).
Constant Summary collapse
- SAFE_NAMES_REGEXP =
%r{\A[a-zA-Z_]+\Z}
Instance Method Summary collapse
- #extract_property_options(options) ⇒ Object
- #indexed? ⇒ Boolean
-
#initialize(name, default, type, options = {}) ⇒ Column
constructor
A new instance of Column.
- #should_create_accessors? ⇒ Boolean
- #validate(value, errors) ⇒ Object
Constructor Details
#initialize(name, default, type, options = {}) ⇒ Column
Returns a new instance of Column.
11 12 13 14 15 |
# File 'lib/property/column.rb', line 11 def initialize(name, default, type, ={}) name = name.to_s () super(name, default, type, ) end |
Instance Method Details
#extract_property_options(options) ⇒ Object
29 30 31 |
# File 'lib/property/column.rb', line 29 def () @indexed = .delete(:indexed) end |
#indexed? ⇒ Boolean
25 26 27 |
# File 'lib/property/column.rb', line 25 def indexed? @indexed end |
#should_create_accessors? ⇒ Boolean
21 22 23 |
# File 'lib/property/column.rb', line 21 def should_create_accessors? name =~ SAFE_NAMES_REGEXP end |
#validate(value, errors) ⇒ Object
17 18 19 |
# File 'lib/property/column.rb', line 17 def validate(value, errors) # Do nothing for the moment end |