Class: Changed::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/changed/builder.rb

Overview

rubocop:disable Metrics/ClassLength

Defined Under Namespace

Classes: ArgumentError

Constant Summary collapse

ARGUMENT_ERROR_EMPTY_KEYS_MESSAGE =
'audited requires specifying a splat of keys'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, *keys) ⇒ Builder

Returns a new instance of Builder.

Raises:



12
13
14
15
16
17
# File 'lib/changed/builder.rb', line 12

def initialize(klass, *keys)
  raise ArgumentError, ARGUMENT_ERROR_EMPTY_KEYS_MESSAGE if keys.empty?

  @klass = klass
  @keys = keys
end

Class Method Details

.build(*args) ⇒ Object



8
9
10
# File 'lib/changed/builder.rb', line 8

def self.build(*args)
  new(*args).build
end

Instance Method Details

#buildObject



19
20
21
22
23
# File 'lib/changed/builder.rb', line 19

def build
  define_callbacks_for_associations
  define_after_create_callback
  define_after_update_callback
end