Module: Ddr::Auth::Roles

Extended by:
ActiveSupport::Autoload
Defined in:
lib/ddr/auth/roles.rb,
lib/ddr/auth/roles/role.rb,
lib/ddr/auth/roles/query.rb,
lib/ddr/auth/roles/editor.rb,
lib/ddr/auth/roles/scopes.rb,
lib/ddr/auth/roles/viewer.rb,
lib/ddr/auth/roles/curator.rb,
lib/ddr/auth/roles/role_set.rb,
lib/ddr/auth/roles/downloader.rb,
lib/ddr/auth/roles/contributor.rb,
lib/ddr/auth/roles/metadata_editor.rb

Defined Under Namespace

Modules: Scopes Classes: Contributor, Curator, Downloader, Editor, MetadataEditor, Query, Role, RoleSet, Viewer

Class Method Summary collapse

Class Method Details

.build_role(args = {}) ⇒ Ddr::Auth::Roles::Role

Builds a new role instance by type and a hash of arguments

Parameters:

  • args (Hash) (defaults to: {})

    the role arguments

Returns:

See Also:



39
40
41
42
# File 'lib/ddr/auth/roles.rb', line 39

def build_role(args={})
  role_type = args.delete(:type)
  get_role_class(role_type).build(args)
end

.get_role_class(role_type) ⇒ Class Also known as: get

Return the class for a type of role specified as a symbol or string

Examples:

get_role_class(:curator) 
=> Ddr::Auth::Roles::Curator

Parameters:

  • role_type (Symbol, String)

    the role type

Returns:

  • (Class)

    the role class



25
26
27
28
29
30
31
# File 'lib/ddr/auth/roles.rb', line 25

def get_role_class(role_type)
  role_class = const_get(role_type.to_s.camelize)
  unless role_class < Role
    raise ArgumentError, "#{role_type.inspect} is not a valid role type."
  end
  role_class
end

.get_scope_term(scope) ⇒ RDF::Vocabulary::Term

Return the RDF term for the scope

Examples:

get_scope_term(:resource) 
=> #<RDF::Vocabulary::Term:0x3fee2204d10c URI:http://repository.lib.duke.edu/vocab/scopes/Resource>

Parameters:

  • scope (Symbol, String)

    the scope

Returns:

  • (RDF::Vocabulary::Term)

    the scope term



50
51
52
# File 'lib/ddr/auth/roles.rb', line 50

def get_scope_term(scope)
  Ddr::Vocab::Scopes.send(scope.to_s.capitalize)
end