Class: Exwiw::BelongsTo
- Inherits:
-
Object
- Object
- Exwiw::BelongsTo
- Includes:
- Serdes
- Defined in:
- lib/exwiw/belongs_to.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#identity ⇒ Object
Structural identity used to match a freshly generated belongs_to against a user-maintained one during merge.
- #polymorphic? ⇒ Boolean
- #to_hash ⇒ Object
Class Method Details
.from_symbol_keys(hash) ⇒ Object
36 37 38 |
# File 'lib/exwiw/belongs_to.rb', line 36 def self.from_symbol_keys(hash) from(hash.transform_keys(&:to_s)) end |
Instance Method Details
#identity ⇒ Object
Structural identity used to match a freshly generated belongs_to against a user-maintained one during merge. ‘comment`/`ignore`/`references` are intentionally excluded so a generated relation matches a hand-edited one regardless of whether either carries a `references`, letting the merge reconcile them (a hand-edited `references` wins over the generated one).
49 50 51 |
# File 'lib/exwiw/belongs_to.rb', line 49 def identity [table_name, foreign_key, foreign_type, type_value] end |
#polymorphic? ⇒ Boolean
40 41 42 |
# File 'lib/exwiw/belongs_to.rb', line 40 def polymorphic? !foreign_type.nil? end |
#to_hash ⇒ Object
53 54 55 |
# File 'lib/exwiw/belongs_to.rb', line 53 def to_hash super.compact end |