Class: GlobalRegistry::Bindings::Options::RelationshipOptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/global_registry_bindings/options/relationship_options_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ RelationshipOptionsParser

Returns a new instance of RelationshipOptionsParser.



7
8
9
# File 'lib/global_registry_bindings/options/relationship_options_parser.rb', line 7

def initialize(model_class)
  @model_class = model_class
end

Instance Method Details

#defaultsObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/global_registry_bindings/options/relationship_options_parser.rb', line 11

def defaults
  {
    binding: :relationship, id_column: :global_registry_id,
    type: @model_class.name.demodulize.underscore.to_sym,
    client_integration_id: :id,
    primary_binding: :entity, primary: nil, primary_class: nil, primary_name: nil, primary_foreign_key: nil,
    related: nil, related_class: nil, related_type: nil, related_name: nil, related_foreign_key: nil,
    related_global_registry_id: nil, related_binding: :entity,
    exclude: %i[id created_at updated_at], include_all_columns: false,
    fields: {}, ensure_type: true, rename_entity_type: true, if: nil, unless: nil
  }.freeze
end

#parse(options_hash = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/global_registry_bindings/options/relationship_options_parser.rb', line 24

def parse(options_hash = {})
  validate_options! options_hash
  merge_defaults(options_hash)
  update_association_classes
  update_foreign_keys
  update_excludes
  @options
end