Sha256: 63087c1423ee0265a7aa7d25e140ad563910048b8f465526634d48f38adc07ec

Contents?: true

Size: 777 Bytes

Versions: 12

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

12 entries across 12 versions & 2 rubygems

Version Path
couch_potato-0.5.4 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.3 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.2 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.1 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.5.0 lib/couch_potato/persistence/active_model_compliance.rb
davber_couch_potato-0.4.0 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.4.0 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.3.2 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.3.1 lib/couch_potato/persistence/active_model_compliance.rb
davber_couch_potato-0.3.0 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.3.0 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.32 lib/couch_potato/persistence/active_model_compliance.rb