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
45 46 47 |
# File 'lib/exwiw/belongs_to.rb', line 45 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).
58 59 60 |
# File 'lib/exwiw/belongs_to.rb', line 58 def identity [table_name, foreign_key, foreign_type, type_value] end |
#polymorphic? ⇒ Boolean
49 50 51 |
# File 'lib/exwiw/belongs_to.rb', line 49 def polymorphic? !foreign_type.nil? end |
#to_hash ⇒ Object
62 63 64 |
# File 'lib/exwiw/belongs_to.rb', line 62 def to_hash super.compact end |