Class: Chartio::ForeignKeyRelationship
- Inherits:
-
Object
- Object
- Chartio::ForeignKeyRelationship
- Defined in:
- lib/chartio/foreign_key_relationship.rb
Constant Summary collapse
- FIELDS =
[ :parent_table, :parent_primary_key, :child_table, :child_foreign_key, :polymorphic_field ]
Instance Method Summary collapse
-
#initialize(*args) ⇒ ForeignKeyRelationship
constructor
A new instance of ForeignKeyRelationship.
- #to_a ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(*args) ⇒ ForeignKeyRelationship
Returns a new instance of ForeignKeyRelationship.
11 12 13 14 15 |
# File 'lib/chartio/foreign_key_relationship.rb', line 11 def initialize(*args) args.each_with_index do |ele, index| instance_variable_set("@#{FIELDS[index]}", ele) end end |
Instance Method Details
#to_a ⇒ Object
17 18 19 |
# File 'lib/chartio/foreign_key_relationship.rb', line 17 def to_a FIELDS.map { |x| self.send(x) } end |
#to_h ⇒ Object
21 22 23 24 25 26 |
# File 'lib/chartio/foreign_key_relationship.rb', line 21 def to_h FIELDS.inject({}) do |hash, element| hash[element] = self.send(element) hash end end |