Class: StoreAgent::User

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/store_agent/user.rb

Overview

オブジェクトの操作を行うユーザー

Direct Known Subclasses

Guest, Superuser

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validator

#validates_to_be_excluded_slash!, #validates_to_be_not_guest_identifier!, #validates_to_be_not_nil_value!, #validates_to_be_not_superuser_identifier!, #validates_to_be_string_or_symbol!

Constructor Details

#initialize(*identifiers) ⇒ User

ユーザーの初期化は以下のようにして行う

StoreAgent::User.new("foo")
StoreAgent::User.new("foo", "bar")
StoreAgent::User.new(["foo", "bar", "baz"])
StoreAgent::User.new("foo", ["bar", "hoge"], "fuga")


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/store_agent/user.rb', line 29

def initialize(*identifiers)
  identifiers.compact!
  if identifiers.empty?
    raise ArgumentError, "identifier(s) is required"
  end
  @identifiers = identifiers.map do |identifier|
    if identifier.is_a?(Array)
      stringify_map_identifier(identifier)
    else
      stringify_identifier(identifier)
    end
  end
end

Instance Attribute Details

#identifiersObject (readonly)

Returns the value of attribute identifiers.



22
23
24
# File 'lib/store_agent/user.rb', line 22

def identifiers
  @identifiers
end

Instance Method Details

#guest?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/store_agent/user.rb', line 55

def guest?
  false
end

#identifierObject



47
48
49
# File 'lib/store_agent/user.rb', line 47

def identifier
  identifier_array.first
end

#identifier_arrayObject

:nodoc:



43
44
45
# File 'lib/store_agent/user.rb', line 43

def identifier_array # :nodoc:
  [identifiers.last].flatten
end

#super_user?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/store_agent/user.rb', line 51

def super_user?
  false
end

#workspace(namespace) ⇒ Object

操作対象のワークスペースを指定する



60
61
62
# File 'lib/store_agent/user.rb', line 60

def workspace(namespace)
  StoreAgent::Workspace.new(current_user: self, namespace: namespace)
end