Sha256: 7289477a5a35a068e54b229429641cd07ed0dbb444f86fd0cd4ea0fa1928d904

Contents?: true

Size: 1 KB

Versions: 33

Compression:

Stored size: 1 KB

Contents

module Sequel
  module Plugins
    # Adds an after_initialize hook to models, called after initializing
    # both new objects and ones loaded from the database.
    #
    # Usage:
    #
    #   # Make all model subclasses support the after_initialize hook
    #   Sequel::Model.plugin :after_initialize
    #
    #   # Make the Album class support the after_initialize hook
    #   Album.plugin :after_initialize
    module AfterInitialize
      module ClassMethods
        # Call after_initialize for model objects loaded from the database.
        def call(h={})
          v = super
          v.after_initialize
          v
        end
      end

      module InstanceMethods
        # Call after_initialize for new model objects.
        def initialize(h={})
          super
          after_initialize
        end
       
        # An empty after_initialize hook, so that plugins that use this
        # can always call super to get the default behavior.
        def after_initialize
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
sequel-4.30.0 lib/sequel/plugins/after_initialize.rb
sequel-4.29.0 lib/sequel/plugins/after_initialize.rb
sequel-4.28.0 lib/sequel/plugins/after_initialize.rb
sequel-4.27.0 lib/sequel/plugins/after_initialize.rb
sequel-4.26.0 lib/sequel/plugins/after_initialize.rb
sequel-4.25.0 lib/sequel/plugins/after_initialize.rb
sequel-4.24.0 lib/sequel/plugins/after_initialize.rb
sequel-4.23.0 lib/sequel/plugins/after_initialize.rb
sequel-4.22.0 lib/sequel/plugins/after_initialize.rb
sequel-4.21.0 lib/sequel/plugins/after_initialize.rb
sequel-4.20.0 lib/sequel/plugins/after_initialize.rb
sequel-4.19.0 lib/sequel/plugins/after_initialize.rb
sequel-4.18.0 lib/sequel/plugins/after_initialize.rb
sequel-4.17.0 lib/sequel/plugins/after_initialize.rb
sequel-4.16.0 lib/sequel/plugins/after_initialize.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/sequel-4.15.0/lib/sequel/plugins/after_initialize.rb
sequel-4.15.0 lib/sequel/plugins/after_initialize.rb
sequel-4.14.0 lib/sequel/plugins/after_initialize.rb
sequel-4.13.0 lib/sequel/plugins/after_initialize.rb
sequel-4.12.0 lib/sequel/plugins/after_initialize.rb