Class: TableSaw::ForeignKey::Column
- Inherits:
-
Object
- Object
- TableSaw::ForeignKey::Column
- Defined in:
- lib/table_saw/foreign_key.rb
Constant Summary collapse
- REGEX =
/(\w+)(?::(\w+)\((\w+)\))?/
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Column
constructor
A new instance of Column.
- #primary_key ⇒ Object
- #type_condition ⇒ Object
Constructor Details
#initialize(value) ⇒ Column
Returns a new instance of Column.
10 11 12 |
# File 'lib/table_saw/foreign_key.rb', line 10 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/table_saw/foreign_key.rb', line 8 def value @value end |
Instance Method Details
#primary_key ⇒ Object
14 15 16 |
# File 'lib/table_saw/foreign_key.rb', line 14 def primary_key value[REGEX, 1] end |
#type_condition ⇒ Object
18 19 20 |
# File 'lib/table_saw/foreign_key.rb', line 18 def type_condition polymorphic? ? "#{type_column} = '#{type_value}'" : '1 = 1' end |