<commit_before>package ORM::EnsEMBL::Rose::CustomColumnValue::DataMap;

## Name: ORM::EnsEMBL::Rose::CustomColumnValue::DataMap
## Class representing the value provided to column type 'datamap'

use strict;

use ORM::EnsEMBL::Utils::Exception;

use base qw(ORM::EnsEMBL::Rose::CustomColumnValue::DataStructure);

sub new {
  ## @overrides
  ## @constructor
  ## @exception If data is not a hash 
  my ($class, $data, $trusted) = @_;
  my $self = $class->SUPER::new($data || {}, $trusted);
  throw('Column of type datatype can only accept stringified hash values.') unless $self->isa('HASH');

  return $self;
}

sub has_key {
  ## Tells whether a key exists in the datamap or not
  ## @param String value of the key
  my ($self, $key) = @_;
  return exists $self->{$key};
}

1;<commit_msg>'deflate' method added to set default values before actually calling parent class's deflate method<commit_after>package ORM::EnsEMBL::Rose::CustomColumnValue::DataMap;

## Class representing the value provided to column type 'datamap'

use strict;

use ORM::EnsEMBL::Utils::Exception;

use base qw(ORM::EnsEMBL::Rose::CustomColumnValue::DataStructure);

sub new {
  ## @override
  ## @constructor
  ## @exception If data is not a hash 
  my ($class, $data) = splice @_, 0, 2;
  my $self = $class->SUPER::new($data || {}, @_);
  throw('Column of type datatype can only accept stringified hash values.') unless $self->isa('HASH');

  return $self;
}

sub deflate {
  ## @override
  ## Adds default values to the virtual keys before deflating the column value
  my ($self, $column) = splice @_, 0, 2;
  $column->set_default_values($self);
  return $self->SUPER::deflate($column, @_);
}

sub has_key {
  ## Tells whether a key exists in the datamap or not
  ## @param String value of the key
  my ($self, $key) = @_;
  return exists $self->{$key};
}

1;
{'fraction_non_alphanumeric': 0.14744287268770404, 'fraction_numerical': 0.003264417845484222, 'mean_word_length': 4.801261829652997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4887784', 'n_tokens_mistral': 628, 'n_tokens_neox': 604, 'n_words': 191}