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.
13
14
15
16
17
|
# File 'lib/foreign_key_checker.rb', line 13
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.
12
13
14
|
# File 'lib/foreign_key_checker.rb', line 12
def association
@association
end
|
#model ⇒ Object
Returns the value of attribute model.
12
13
14
|
# File 'lib/foreign_key_checker.rb', line 12
def model
@model
end
|
Instance Method Details
#from_column ⇒ Object
27
28
29
|
# File 'lib/foreign_key_checker.rb', line 27
def from_column
association.foreign_key
end
|
#from_table ⇒ Object
19
20
21
|
# File 'lib/foreign_key_checker.rb', line 19
def from_table
model.table_name
end
|
#human_relation ⇒ Object
35
36
37
|
# File 'lib/foreign_key_checker.rb', line 35
def human_relation
"#{from_table} belongs_to #{to_table} (by column #{from_column} to #{to_column})"
end
|
#inspect ⇒ Object
41
42
43
|
# File 'lib/foreign_key_checker.rb', line 41
def inspect
"#<#{self.class.name}:#{self.object_id} #{message}>"
end
|
#message ⇒ Object
39
|
# File 'lib/foreign_key_checker.rb', line 39
def message; end
|
#nullable? ⇒ Boolean
45
46
47
|
# File 'lib/foreign_key_checker.rb', line 45
def nullable?
model.columns_hash[from_column.to_s].null
end
|
#to_column ⇒ Object
31
32
33
|
# File 'lib/foreign_key_checker.rb', line 31
def to_column
association.klass.primary_key
end
|
#to_table ⇒ Object
23
24
25
|
# File 'lib/foreign_key_checker.rb', line 23
def to_table
association.klass.table_name
end
|