Sha256: 80f920c36f3448dee75711025d68a77d45544c94d1f4996999e5c33ddc894f72

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

class Account < CurlyMustache::Base
  attribute :name, :string, :allow_nil => false
  attribute :created_at, :time
  attribute :updated_at, :time
  
  CALLBACKS = %w[before_create after_create
                 before_save after_save
                 before_update after_update
                 before_destroy after_destroy
                 before_validation after_validation
                 before_validation_on_create after_validation_on_create
                 before_validation_on_update after_validation_on_update
                 after_find]
  
  attr_accessor :callbacks_made
  
  # This just defines methods for each callback that simply records in #callbacks_made that
  # the callback was called.
  CALLBACKS.each do |callback_name|
    class_eval <<-end_eval
      #{callback_name} :#{callback_name}_cb
      def #{callback_name}_cb
        @callbacks_made ||= []
        @callbacks_made << :#{callback_name}
      end
    end_eval
  end
  
  validates_presence_of :name
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curly_mustache-0.1.0 test/models/account.rb