Class: Fog::Bouncer::Sources::Group

Inherits:
Fog::Bouncer::Source show all
Defined in:
lib/fog/bouncer/sources.rb

Instance Attribute Summary collapse

Attributes inherited from Fog::Bouncer::Source

#group, #local, #remote, #source

Instance Method Summary collapse

Methods inherited from Fog::Bouncer::Source

#==, #add_protocol, #extras, #inspect, #local?, #missing, #protocols, #remote?

Constructor Details

#initialize(source, group, &block) ⇒ Group

Returns a new instance of Group.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/bouncer/sources.rb', line 40

def initialize(source, group, &block)
  super
  case source
  when /^(.+)@(.+)$/
    @name = $1
    @user_alias = $2
    if @user_alias[/^\d+$/]
      @user_id = @user_alias
      if  = group.security.accounts.find { |key, id| id == @user_id }
        @user_alias = [0]
      end
    end
  else
    @name = source
    @user_alias = 'self'
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/fog/bouncer/sources.rb', line 38

def name
  @name
end

#user_aliasObject (readonly)

Returns the value of attribute user_alias.



38
39
40
# File 'lib/fog/bouncer/sources.rb', line 38

def user_alias
  @user_alias
end

#user_idObject (readonly)

Returns the value of attribute user_id.



38
39
40
# File 'lib/fog/bouncer/sources.rb', line 38

def user_id
  @user_id
end

Instance Method Details

#match(source) ⇒ Object



58
59
60
# File 'lib/fog/bouncer/sources.rb', line 58

def match(source)
  "#{name}@#{user_id}" == source || "#{name}@#{user_alias}" == source || name == source
end