Sha256: 2144d4005ce7695183302521cfe8ce017359f3be36ebc305e87c5db4566c63a2
Contents?: true
Size: 979 Bytes
Versions: 1
Compression:
Stored size: 979 Bytes
Contents
# frozen_string_literal: true module PUNK # @model # @property id(required) [string] a unique identifier for the user # @property name(required) [string] the name of the user # @property icon(required) [string] an image URL class User < Model alias_method :to_s, :name many_to_many :tenants many_to_many :groups one_to_many :identities many_through_many :sessions, through: [[:identities, :user_id, :id], [:sessions, :identity_id, :id]] def validate validates_presence :name validates_url :icon, allow_blank: true validates_presence :email if phone.blank? validates_presence :phone if email.blank? validates_email :email, allow_blank: true validates_phone :phone, allow_blank: true validates_unique :email, allow_blank: true validates_unique :phone, allow_blank: true end def active_sessions sessions_dataset.where(Sequel.lit('"sessions"."state"') => "active") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
punk-0.4.1 | lib/punk/models/user.rb |