Sha256: 0759861c8b7020199f3ac2a5cc77b0ecf633974e29a7abf2abd5611231708e07

Contents?: true

Size: 445 Bytes

Versions: 2

Compression:

Stored size: 445 Bytes

Contents

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guise-0.6.0 lib/guise/callbacks.rb
guise-0.5.0 lib/guise/callbacks.rb