Module: Clerk

Defined in:
lib/clerk.rb,
lib/clerk/railtie.rb,
lib/clerk/version.rb,
lib/clerk/callback.rb,
lib/clerk/configuration.rb

Defined Under Namespace

Classes: Callback, Configuration, Railtie

Constant Summary collapse

VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



5
6
7
# File 'lib/clerk/configuration.rb', line 5

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



8
9
10
11
# File 'lib/clerk/configuration.rb', line 8

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

Instance Method Details

#track_who_does_it(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/clerk.rb', line 9

def track_who_does_it(options = {})
  before_create Clerk::Callback.new
  before_update Clerk::Callback.new

  creator_fk = options.fetch(:creator_foreign_key) { "created_by_id" }
  updater_fk = options.fetch(:updater_foreign_key) { "updated_by_id" }

  belongs_to :creator, :class_name => "User", :foreign_key => creator_fk, :optional => true
  belongs_to :updater, :class_name => "User", :foreign_key => updater_fk, :optional => true
end