Class: Property::Column

Inherits:
ActiveRecord::ConnectionAdapters::Column
  • Object
show all
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

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, options={})
  name = name.to_s
  extract_property_options(options)
  super(name, default, type, options)
end

Instance Method Details

#extract_property_options(options) ⇒ Object



29
30
31
# File 'lib/property/column.rb', line 29

def extract_property_options(options)
  @indexed = options.delete(:indexed)
end

#indexed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/property/column.rb', line 25

def indexed?
  @indexed
end

#should_create_accessors?Boolean

Returns:

  • (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