Sha256: a3937caaeb5500f7dac99302aa53988b5a9be17f1b79fd8d018d69ff4d7fab4c

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 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, :external_apps

    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 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.13.0 lib/auth_lh/user.rb