Sha256: bfd3ffb7d2ee5780dff5b99a6fd3c6951a87723a6384b4b4e9113c22b429e970

Contents?: true

Size: 777 Bytes

Versions: 9

Compression:

Stored size: 777 Bytes

Contents

module CouchPotato
  module Persistence
    module ActiveModelCompliance
      begin
        require 'active_model'

        def self.included(base)
          base.extend ClassMethods
        end

        def to_model
          self
        end

        def errors
          super || {}
        end
        
        def persisted?
          !self.new?
        end
        
        def to_key
          persisted? ? [to_param] : nil
        end

        def destroyed?
          !!_deleted
        end

        module ClassMethods
          def model_name
            @model_name ||= ::ActiveModel::Name.new(self)
          end
        end

      rescue LoadError, NameError
        # if it's not installed you probably don't want to use it anyway
      end
    end
  end
end


Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
couch_potato-0.6.0 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.7 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-rails2-0.5.10 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-rails2-0.5.9 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-rails2-0.5.8 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-rails2-0.5.7 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-rails2-0.5.6 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.6 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.5 lib/couch_potato/persistence/active_model_compliance.rb