Module: Sinatra::RoleDescriber
- Defined in:
- lib/belphanior/servant/role_builder.rb
Defined Under Namespace
Classes: BadParameterException
Instance Method Summary collapse
-
#add_role_description(description) ⇒ Object
Adds a new role description.
Instance Method Details
#add_role_description(description) ⇒ Object
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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 |