Class: GlobalRegistry::Bindings::Options::EntityOptionsParser

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

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ EntityOptionsParser

Returns a new instance of EntityOptionsParser.



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

def initialize(model_class)
  @model_class = model_class
end

Instance Method Details

#defaultsObject

rubocop:disable Metrics/MethodLength



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/global_registry_bindings/options/entity_options_parser.rb', line 11

def defaults # rubocop:disable Metrics/MethodLength
  {
    binding: :entity,
    id_column: :global_registry_id,
    mdm_id_column: nil,
    fingerprint_column: nil,
    type: @model_class.name.demodulize.underscore.to_sym,
    push_on: %i[create update destroy],
    parent: nil,
    parent_class: nil,
    exclude: %i[id created_at updated_at],
    fields: {},
    include_all_columns: false,
    mdm_timeout: 1.minute,
    ensure_type: true,
    if: nil, unless: nil
  }.freeze
end

#parse(options_hash = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/global_registry_bindings/options/entity_options_parser.rb', line 30

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