Class: ModelColumn
Overview
Field metadata class. Includes information for type, reflections etc.
Also, it eases the migration from AR to Sequel, which returns metadata as a hash instead of a class.
Instance Attribute Summary collapse
-
#after_add ⇒ Object
sequel::Model.reflections.
-
#after_load ⇒ Object
sequel::Model.reflections.
-
#after_remove ⇒ Object
sequel::Model.reflections.
-
#after_set ⇒ Object
sequel::Model.reflections.
-
#allow_null ⇒ Object
these are from Sequel::Model.columns_hash.
-
#association ⇒ Object
added by us.
-
#before_add ⇒ Object
sequel::Model.reflections.
-
#before_remove ⇒ Object
sequel::Model.reflections.
-
#before_set ⇒ Object
sequel::Model.reflections.
-
#block ⇒ Object
new in sequel 3.25.0.
-
#cache ⇒ Object
sequel::Model.reflections.
-
#cartesian_product_number ⇒ Object
For Sequel many_to_many.
-
#class ⇒ Object
TODO not sure where these are from.
-
#class_name ⇒ Object
sequel::Model.reflections.
-
#conditions ⇒ Object
TODO not sure where these are from.
-
#dataset ⇒ Object
sequel::Model.reflections.
-
#db_type ⇒ Object
these are from Sequel::Model.columns_hash.
-
#default ⇒ Object
these are from AR.
-
#eager_block ⇒ Object
sequel::Model.reflections.
-
#eager_grapher ⇒ Object
sequel::Model.reflections.
-
#eager_loader ⇒ Object
sequel::Model.reflections.
-
#extend ⇒ Object
sequel::Model.reflections.
-
#graph_alias_base ⇒ Object
new in sequel 3.30.0.
-
#graph_conditions ⇒ Object
sequel::Model.reflections.
-
#graph_join_table_conditions ⇒ Object
For Sequel many_to_many.
-
#graph_join_table_join_type ⇒ Object
For Sequel many_to_many.
-
#graph_join_type ⇒ Object
sequel::Model.reflections.
-
#join_table ⇒ Object
For Sequel many_to_many.
-
#key ⇒ Object
sequel::Model.reflections.
-
#keys ⇒ Object
sequel::Model.reflections.
-
#left_key ⇒ Object
For Sequel many_to_many.
-
#left_key_alias ⇒ Object
For Sequel many_to_many.
-
#left_keys ⇒ Object
For Sequel many_to_many.
-
#left_primary_key ⇒ Object
For Sequel many_to_many.
-
#left_primary_keys ⇒ Object
For Sequel many_to_many.
-
#limit ⇒ Object
if it’s not here, it’s probably from Sequel, so figure it out from the db_type.
-
#meta ⇒ Object
these are from AR.
-
#model ⇒ Object
sequel::Model.reflections.
-
#name ⇒ Object
sequel::Model.reflections.
-
#order ⇒ Object
TODO not sure where these are from.
-
#order_eager_graph ⇒ Object
sequel::Model.reflections.
-
#orig_opts ⇒ Object
sequel::Model.reflections.
-
#precision ⇒ Object
these are from AR.
-
#primary ⇒ Object
these are from AR.
-
#primary_key ⇒ Object
these are from Sequel::Model.columns_hash.
-
#primary_keys ⇒ Object
for many_to_one targets.
-
#qualified_key ⇒ Object
Returns the value of attribute qualified_key.
-
#reciprocal ⇒ Object
sequel::Model.reflections.
-
#reciprocal_type ⇒ Object
sequel::Model.reflections.
-
#right_key ⇒ Object
For Sequel many_to_many.
-
#right_keys ⇒ Object
For Sequel many_to_many.
-
#ruby_default ⇒ Object
these are from Sequel::Model.columns_hash.
-
#scale ⇒ Object
these are from AR.
-
#sql_type ⇒ Object
these are from AR.
-
#type ⇒ Object
sequel::Model.reflections.
-
#uses_composite_keys ⇒ Object
sequel::Model.reflections.
-
#uses_left_composite_keys ⇒ Object
For Sequel many_to_many.
-
#uses_right_composite_keys ⇒ Object
For Sequel many_to_many.
Instance Method Summary collapse
- #association? ⇒ Boolean
-
#initialize(name, hash) ⇒ ModelColumn
constructor
A new instance of ModelColumn.
- #related_class ⇒ Object
Constructor Details
#initialize(name, hash) ⇒ ModelColumn
Returns a new instance of ModelColumn.
62 63 64 65 66 67 68 69 70 |
# File 'lib/clevic/model_column.rb', line 62 def initialize( name, hash ) @hash = hash @hash.each do |key,value| send( "#{key}=", value ) end # must be after hash so it takes precedence @name = name end |
Instance Attribute Details
#after_add ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def after_add @after_add end |
#after_load ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def after_load @after_load end |
#after_remove ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def after_remove @after_remove end |
#after_set ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def after_set @after_set end |
#allow_null ⇒ Object
these are from Sequel::Model.columns_hash
25 26 27 |
# File 'lib/clevic/model_column.rb', line 25 def allow_null @allow_null end |
#association ⇒ Object
added by us
59 60 61 |
# File 'lib/clevic/model_column.rb', line 59 def association @association end |
#before_add ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def before_add @before_add end |
#before_remove ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def before_remove @before_remove end |
#before_set ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def before_set @before_set end |
#block ⇒ Object
new in sequel 3.25.0
37 38 39 |
# File 'lib/clevic/model_column.rb', line 37 def block @block end |
#cache ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def cache @cache end |
#cartesian_product_number ⇒ Object
For Sequel many_to_many
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def cartesian_product_number @cartesian_product_number end |
#class ⇒ Object
TODO not sure where these are from
34 35 36 |
# File 'lib/clevic/model_column.rb', line 34 def class @class end |
#class_name ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def class_name @class_name end |
#conditions ⇒ Object
TODO not sure where these are from
34 35 36 |
# File 'lib/clevic/model_column.rb', line 34 def conditions @conditions end |
#dataset ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def dataset @dataset end |
#db_type ⇒ Object
these are from Sequel::Model.columns_hash
25 26 27 |
# File 'lib/clevic/model_column.rb', line 25 def db_type @db_type end |
#default ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def default @default end |
#eager_block ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def eager_block @eager_block end |
#eager_grapher ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def eager_grapher @eager_grapher end |
#eager_loader ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def eager_loader @eager_loader end |
#extend ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def extend @extend end |
#graph_alias_base ⇒ Object
new in sequel 3.30.0
40 41 42 |
# File 'lib/clevic/model_column.rb', line 40 def graph_alias_base @graph_alias_base end |
#graph_conditions ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def graph_conditions @graph_conditions end |
#graph_join_table_conditions ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def graph_join_table_conditions @graph_join_table_conditions end |
#graph_join_table_join_type ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def graph_join_table_join_type @graph_join_table_join_type end |
#graph_join_type ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def graph_join_type @graph_join_type end |
#join_table ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def join_table @join_table end |
#key ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def key @key end |
#keys ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def keys @keys end |
#left_key ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def left_key @left_key end |
#left_key_alias ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def left_key_alias @left_key_alias end |
#left_keys ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def left_keys @left_keys end |
#left_primary_key ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def left_primary_key @left_primary_key end |
#left_primary_keys ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def left_primary_keys @left_primary_keys end |
#limit ⇒ Object
if it’s not here, it’s probably from Sequel, so figure it out from the db_type
16 17 18 19 20 21 22 |
# File 'lib/clevic/model_column.rb', line 16 def limit unless @limit db_type =~ /\((\d+)\)/ @limit = $1.to_i end @limit end |
#meta ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def @meta end |
#model ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def model @model end |
#name ⇒ Object
sequel::Model.reflections
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def name @name end |
#order ⇒ Object
TODO not sure where these are from
34 35 36 |
# File 'lib/clevic/model_column.rb', line 34 def order @order end |
#order_eager_graph ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def order_eager_graph @order_eager_graph end |
#orig_opts ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def orig_opts @orig_opts end |
#precision ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def precision @precision end |
#primary ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def primary @primary end |
#primary_key ⇒ Object
these are from Sequel::Model.columns_hash
25 26 27 |
# File 'lib/clevic/model_column.rb', line 25 def primary_key @primary_key end |
#primary_keys ⇒ Object
for many_to_one targets
31 32 33 |
# File 'lib/clevic/model_column.rb', line 31 def primary_keys @primary_keys end |
#qualified_key ⇒ Object
Returns the value of attribute qualified_key.
41 42 43 |
# File 'lib/clevic/model_column.rb', line 41 def qualified_key @qualified_key end |
#reciprocal ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def reciprocal @reciprocal end |
#reciprocal_type ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def reciprocal_type @reciprocal_type end |
#right_key ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def right_key @right_key end |
#right_keys ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def right_keys @right_keys end |
#ruby_default ⇒ Object
these are from Sequel::Model.columns_hash
25 26 27 |
# File 'lib/clevic/model_column.rb', line 25 def ruby_default @ruby_default end |
#scale ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def scale @scale end |
#sql_type ⇒ Object
these are from AR
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def sql_type @sql_type end |
#type ⇒ Object
sequel::Model.reflections
10 11 12 |
# File 'lib/clevic/model_column.rb', line 10 def type @type end |
#uses_composite_keys ⇒ Object
sequel::Model.reflections
28 29 30 |
# File 'lib/clevic/model_column.rb', line 28 def uses_composite_keys @uses_composite_keys end |
#uses_left_composite_keys ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def uses_left_composite_keys @uses_left_composite_keys end |
#uses_right_composite_keys ⇒ Object
For Sequel many_to_many
44 45 46 |
# File 'lib/clevic/model_column.rb', line 44 def uses_right_composite_keys @uses_right_composite_keys end |
Instance Method Details
#association? ⇒ Boolean
60 |
# File 'lib/clevic/model_column.rb', line 60 def association?; association; end |
#related_class ⇒ Object
76 77 78 |
# File 'lib/clevic/model_column.rb', line 76 def @related_class ||= eval class_name end |