Module: RightSignature::Helpers::RolesHelper
- Defined in:
- lib/rightsignature/helpers/normalizing.rb
Overview
:nodoc:
Class Method Summary collapse
-
.array_to_xml_hash(roles_array) ⇒ Object
Converts [=> {:name => “John”, :email => “[email protected]”}] to [=> {:name => “John”, :email => “[email protected]”, “@role_id” => “Role_ID” }] Tries to guess if it’s using Role ID or Role Name.
Class Method Details
.array_to_xml_hash(roles_array) ⇒ Object
Converts [=> {:name => “John”, :email => “[email protected]”}] to
[{:role => {:name => "John", :email => "[email protected]", "@role_id" => "Role_ID"} }]
Tries to guess if it’s using Role ID or Role Name
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rightsignature/helpers/normalizing.rb', line 87 def array_to_xml_hash(roles_array) roles_hash_array = [] roles_array.each do |role_hash| name, value = role_hash.first raise "Hash '#{role_hash.inspect}' is malformed, should be something like {ROLE_NAME => {:name => \"a\", :email => \"[email protected]\"}}" unless value.is_a? Hash and (name.is_a? String or name.is_a? Symbol) if name.match(/^signer_[A-Z]+$/) || name.match(/^cc_[A-Z]+$/) roles_hash_array << {:role => value.merge({"@role_id" => name.to_s})} else roles_hash_array << {:role => value.merge({"@role_name" => name.to_s})} end end roles_hash_array end |