Sha256: a69c33e549cb594344a14f567724e24e13e82452fa37fa00cbff84d2f0953e03

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

module AuthLh
  class User
    attr_accessor :email, :jabber, :name, :login, :shop_code,
    :shop_id, :shop_name, :enabled, :role_codes, :password_expired,
    :dni, :has_attendance_control, :has_remote_desktop,
    :fingerprint_from, :fingerprint_to

    def initialize(attributes={})
      attributes.each do |k,v|
        if k.to_s == 'external_apps'
          self.external_apps = v.map { |x| ExternalApp.new(x) }
        else
          self.send("#{k}=", v)
        end
      end
    end

    def password_expired?
      password_expired == true
    end

    def has_role?(role_code)
      role_codes.include?(role_code.to_s)
    end

    def has_some_role?(r_codes)
      r_codes.any? { |r_code|
        role_codes.include?(r_code.to_s)
      }
    end

    def has_all_roles?(r_codes)
      r_codes.all? { |r_code|
        role_codes.include?(r_code.to_s)
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auth-lh-0.11.0 lib/auth_lh/user.rb