Class: ForeignKeyChecker::Result
- Inherits:
-
Object
- Object
- ForeignKeyChecker::Result
show all
- Defined in:
- lib/foreign_key_checker.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Result
Returns a new instance of Result.
8
9
10
11
12
|
# File 'lib/foreign_key_checker.rb', line 8
def initialize(data)
data.each do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Instance Attribute Details
#association ⇒ Object
Returns the value of attribute association.
7
8
9
|
# File 'lib/foreign_key_checker.rb', line 7
def association
@association
end
|
#model ⇒ Object
Returns the value of attribute model.
7
8
9
|
# File 'lib/foreign_key_checker.rb', line 7
def model
@model
end
|
Instance Method Details
#from_column ⇒ Object
22
23
24
|
# File 'lib/foreign_key_checker.rb', line 22
def from_column
association.foreign_key
end
|
#from_table ⇒ Object
14
15
16
|
# File 'lib/foreign_key_checker.rb', line 14
def from_table
model.table_name
end
|
#human_relation ⇒ Object
30
31
32
|
# File 'lib/foreign_key_checker.rb', line 30
def human_relation
"#{from_table} belongs_to #{to_table} (by column #{from_column} to #{to_column})"
end
|
#inspect ⇒ Object
36
37
38
|
# File 'lib/foreign_key_checker.rb', line 36
def inspect
"#<#{self.class.name}:#{self.object_id} #{message}>"
end
|
#message ⇒ Object
34
|
# File 'lib/foreign_key_checker.rb', line 34
def message; end
|
#nullable? ⇒ Boolean
40
41
42
|
# File 'lib/foreign_key_checker.rb', line 40
def nullable?
model.columns_hash[from_column.to_s].null
end
|
#to_column ⇒ Object
26
27
28
|
# File 'lib/foreign_key_checker.rb', line 26
def to_column
association.klass.primary_key
end
|
#to_table ⇒ Object
18
19
20
|
# File 'lib/foreign_key_checker.rb', line 18
def to_table
association.klass.table_name
end
|