Module: DatastaxRails::AttributeMethods::Typecasting::ClassMethods
- Defined in:
- lib/datastax_rails/attribute_methods/typecasting.rb
Overview
:nodoc:
Attribute Types collapse
-
#array(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#binary(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#boolean(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#date(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#datetime(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#double(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#float(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#integer(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#list(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#long(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#map(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#set(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#string(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#text(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#time(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#timestamp(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#timestamps(options = {}) ⇒ Object
Declare the timestamps attribute type method.
-
#uuid(name, options = {}) ⇒ Object
Declare an attribute of the given type.
Instance Method Summary collapse
-
#column_defaults ⇒ Object
Returns a hash where the keys are column names and the values are default values when instantiating the DSR object for this table.
-
#columns_hash ⇒ Object
Provide some measure of compatibility with things that expect this from ActiveRecord.
-
#inherited(child) ⇒ Object
We need to ensure that inherited classes get their own attribute definitions.
-
#map_columns ⇒ Object
Gives you all of the map columns (useful for detecting dynamic columns).
Instance Method Details
#array(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#binary(name, options = {}) ⇒ Object
Declare an attribute of the given type
67 68 69 70 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 67 def binary(name, = {}) .reverse_merge!(lazy: true) attribute(name, .update(type: :binary)) end |
#boolean(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#column_defaults ⇒ Object
Returns a hash where the keys are column names and the values are default values when instantiating the DSR object for this table.
50 51 52 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 50 def column_defaults @column_defaults ||= Hash[columns.map { |c| [c.name.to_s, c.default] }] end |
#columns_hash ⇒ Object
Provide some measure of compatibility with things that expect this from ActiveRecord.
39 40 41 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 39 def columns_hash attribute_definitions end |
#date(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#datetime(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#double(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#float(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#inherited(child) ⇒ Object
We need to ensure that inherited classes get their own attribute definitions.
55 56 57 58 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 55 def inherited(child) super child.attribute_definitions = attribute_definitions.dup end |
#integer(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#list(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#long(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#map(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#map_columns ⇒ Object
Gives you all of the map columns (useful for detecting dynamic columns)
44 45 46 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 44 def map_columns @map_columns ||= attribute_definitions.values.select { |c| c.type == :map } end |
#set(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#string(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#text(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#time(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#timestamp(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|
#timestamps(options = {}) ⇒ Object
Declare the timestamps attribute type method. Creates both the created_at and updated_at attributes with type time
.
76 77 78 79 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 76 def ( = {}) attribute(:created_at, .update(type: :timestamp)) attribute(:updated_at, .update(type: :timestamp)) end |
#uuid(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 81
|