module Sinatra::RoleDescriber
Public Instance Methods
add_role_description(description)
click to toggle source
Adds a new role description. Note: this is a VERY quick-and-dirty hack; the added description isn’t vetted for format conformance at all.
# File lib/belphanior/servant/role_builder.rb, line 49 def add_role_description(description) if not RoleBuilderUtils::is_valid_identifier?(description["name"]) raise BadParameterException, "Role name was not a valid identifier." end name_as_identifier = RoleBuilderUtils::identifier_to_url_component(description["name"]) description_local_url = "/role_descriptions/" + name_as_identifier description_as_json = JSON.generate description get description_local_url do BelphaniorServantHelper.text_out_as_json(description_as_json) end role_index = implementation["roles"].length implementation["roles"] << { "role_url" => "", "handlers" => [] } if implementation["roles"][role_index]["role_url"] == "" then implementation["roles"][role_index]["role_url"] = ( "/role_descriptions/" + name_as_identifier) end end