Sha256: 96bf844f4336867f380cf737495f55613e8734ed1ae40a5455b48634de64d3c6

Contents?: true

Size: 496 Bytes

Versions: 4

Compression:

Stored size: 496 Bytes

Contents

module Guise
  # @api private
  class Callback
    def initialize(guise, attribute)
      @guise = guise
      @attribute = attribute
    end
  end

  # @api private
  class SourceCallback < Callback
    def after_initialize(record)
      if record.new_record?
        record.guises.build(@attribute => @guise)
      end
    end
  end

  # @api private
  class AssociationCallback < Callback
    def after_initialize(record)
      record.assign_attributes(@attribute => @guise)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
guise-0.9.0 lib/guise/callbacks.rb
guise-0.8.0 lib/guise/callbacks.rb
guise-0.7.0 lib/guise/callbacks.rb
guise-0.6.1 lib/guise/callbacks.rb