Title: [opsview] [11714] Added function used in commercial branch
- Revision
- 11714
- Author
- tvoon
- Date
- 2013-03-11 13:33:20 +0000 (Mon, 11 Mar 2013)
Log Message
Added function used in commercial branch
Modified Paths
Modified: trunk/opsview-core/lib/Opsview/Utils.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Utils.pm 2013-03-11 13:11:15 UTC (rev 11713)
+++ trunk/opsview-core/lib/Opsview/Utils.pm 2013-03-11 13:33:20 UTC (rev 11714)
@@ -32,7 +32,7 @@
our @EXPORT =
qw(max_state max_state_text convert_state_to_text convert_host_state_to_text convert_to_arrayref);
our @EXPORT_OK =
- qw(escape_xml_data escape_xml convert_state_type_to_text convert_perl_regexp_to_js_string apidatatidy convert_uoms unique_objects set_highest_state set_highest_service_state get_ssh_version get_first_hash_key convert_text_to_state_type);
+ qw(merge_hashes escape_xml_data escape_xml convert_state_type_to_text convert_perl_regexp_to_js_string apidatatidy convert_uoms unique_objects set_highest_state set_highest_service_state get_ssh_version get_first_hash_key convert_text_to_state_type);
# This package is for utility functions that do not
# require the database
@@ -517,6 +517,36 @@
return $ssh_version;
}
+=item merge_hashes
+
+copied from Catalyst::Utils::merge_hashes to avoid loading Class::MOP
+
+=cut
+
+#<<< skip perlitdy
+sub merge_hashes {
+ my ( $lefthash, $righthash ) = @_;
+
+ return $lefthash unless defined $righthash;
+
+ my %merged = %$lefthash;
+ for my $key ( keys %$righthash ) {
+ my $right_ref = ( ref $righthash->{ $key } || '' ) eq 'HASH';
+ my $left_ref = ( ( exists $lefthash->{ $key } && ref $lefthash->{ $key } ) || '' ) eq 'HASH';
+ if( $right_ref and $left_ref ) {
+ $merged{ $key } = merge_hashes(
+ $lefthash->{ $key }, $righthash->{ $key }
+ );
+ }
+ else {
+ $merged{ $key } = $righthash->{ $key };
+ }
+ }
+
+ return \%merged;
+}
+#>>> skip perlitdy
+
=back
=head1 AUTHOR
_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins