Sha256: 97eea7a9e09085dfd59be123c8bfc8a05356c5f9e01af62e88687c178163183d

Contents?: true

Size: 577 Bytes

Versions: 3

Compression:

Stored size: 577 Bytes

Contents

module Dust
  class Session
    include ActiveModel::Validations
    include ActiveModel::Conversion
    extend ActiveModel::Naming

    attr_accessor :username, :password, :user, :remember_me

    validates_presence_of :username, :password
    validate :found_user?

    def initialize(attributes=nil, user=nil)
      attributes ||= {}
      @user = user
      attributes.each do |name, value|
        send("#{name}=", value)
      end
    end

    def found_user?
      errors[:base] << "User not found" unless @user
    end

    def persisted?
      false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dust-cms-0.0.07 app/models/dust/session.rb
dust-cms-0.0.06 app/models/dust/session.rb
dust-cms-0.0.05 app/models/dust/session.rb