Module: DatastaxRails::AttributeMethods::Typecasting::ClassMethods
- Defined in:
- lib/datastax_rails/attribute_methods/typecasting.rb
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.
-
#float(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#integer(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#json(name, options = {}) ⇒ Object
Declare an attribute of the given type.
-
#list(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.
-
#time_with_zone(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 84
|
#binary(name, options = {}) ⇒ Object
Declare an attribute of the given type
70 71 72 73 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 70 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 84
|
#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.
53 54 55 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 53 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.
42 43 44 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 42 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 84
|
#datetime(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#float(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#inherited(child) ⇒ Object
We need to ensure that inherited classes get their own attribute definitions.
58 59 60 61 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 58 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 84
|
#json(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#list(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#map(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#map_columns ⇒ Object
Gives you all of the map columns (useful for detecting dynamic columns)
47 48 49 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 47 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 84
|
#string(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#text(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#time(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#time_with_zone(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#timestamp(name, options = {}) ⇒ Object
Declare an attribute of the given type
|
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 84
|
#timestamps(options = {}) ⇒ Object
Declare the timestamps attribute type method. Creates both the created_at and updated_at attributes with type time
.
79 80 81 82 |
# File 'lib/datastax_rails/attribute_methods/typecasting.rb', line 79 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 84
|