Sha256: bf90b5fa188db0f3e1f8661bdc1748616c7da371311ff0e38b3c63b23acf5b15
Contents?: true
Size: 825 Bytes
Versions: 3
Compression:
Stored size: 825 Bytes
Contents
# ActiveModel is not defined as gem dependency but we still depend on it (for now). # With this technique we can use Perimeter in Rails 2 applications by backporting activemodel manually into the vendor directory. require 'active_model' require 'active_support/core_ext/module' require 'active_support/concern' require 'virtus' module Perimeter module Entity extend ActiveSupport::Concern included do include Virtus.model extend ActiveModel::Naming include ActiveModel::Conversion include ActiveModel::Validations include ActiveModel::Validations::Callbacks attribute :id end def to_param return if id.blank? id.to_s end def persisted? # Rails 3+ id.present? end def new_record? # Rails 2 !persisted? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
perimeter-0.0.3 | lib/perimeter/entity.rb |
perimeter-0.0.2 | lib/perimeter/entity.rb |
perimeter-0.0.1 | lib/perimeter/entity.rb |