Sha256: 5bda47f5409c25599f2c7c7eca753c69caf1f7cba50898ca4b8c58fd0067e4ca

Contents?: true

Size: 632 Bytes

Versions: 9

Compression:

Stored size: 632 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 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 & 1 rubygems

Version Path
couch_potato-0.2.31 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.30 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.29 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.28 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.27 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.26 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.25 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.24 lib/couch_potato/persistence/active_model_compliance.rb
couch_potato-0.2.23 lib/couch_potato/persistence/active_model_compliance.rb