Build a hash for all the non-relationship fields
 meaning string, text, date, boolean, select, file types.
 This hash stores their name and their value.

 @return [ Hash ] Field name / formatted value
767851
def custom_fields_basic_attributes
      {}.tap do |hash|
        self.non_relationship_custom_fields.each do |rule|
          name, type = rule['name'], rule['type'].to_sym

          # method of the custom getter
          method_name = "#{type}_attribute_get"

          hash.merge!(self.class.send(method_name, self, name))
        end
      end
    end
484275
def to_hash
      doc = ::Nokogiri::XML( self.response )
      hash = {}
      doc.at_css("Response").element_children.each do |attribute|
        hash[attribute.name.underscore.to_sym] = attribute.inner_text
      end
      hash[:valid] = doc.at_css("Response")['valid']
      hash
    end
198116
def to_hash_with_values
      keys = table_header_keys
      values = self
      @hash_with_values = {}
      keys.each_with_index {|k,i| v=values[i]; v=v.value if v; @hash_with_values[k]=v}
      return @hash_with_values
    end
1116778
def time_to_hash(keys_case)
			raise Exception.new("Invalid time value: nil") if self.time.nil?
			
			# Custom date range
			if time.is_a?(Hash)
				return {
					get_attribute_key("custom_date_range_end", keys_case) => {
						get_attribute_key("day", keys_case) => self.time[:custom_date_range_end][:day],
						get_attribute_key("month", keys_case) => self.time[:custom_date_range_end][:month],
						get_attribute_key("year", keys_case) => self.time[:custom_date_range_end][:year],
						
					},
					get_attribute_key("custom_date_range_start", keys_case) => {
						get_attribute_key("day", keys_case) => self.time[:custom_date_range_start][:day],
						get_attribute_key("month", keys_case) => self.time[:custom_date_range_start][:month],
						get_attribute_key("year", keys_case) => self.time[:custom_date_range_start][:year],
					}
				}
			# Time periods
			else
				return TIME_PERIODS[time.to_s]
			end
		end
1180594
def custom_fields_safe_setters
      self.custom_fields_recipe['rules'].map do |rule|
        case rule['type'].to_sym
        when :date, :date_time, :money  then "formatted_#{rule['name']}"
        when :file                      then [rule['name'], "remove_#{rule['name']}", "remote_#{rule['name']}_url"]
        when :select, :belongs_to       then ["#{rule['name']}_id", "position_in_#{rule['name']}"]
        when :has_many, :many_to_many   then nil
        else
          rule['name']
        end
      end.compact.flatten
    end
187788
def add_line_hash(value_hash)
      @lines << value_hash
      if value_hash[:compound]
        value_hash.each do |key, value|
          if value_hash[:compound].include?(key)
            @attributes[key] = [] if @attributes[key].nil?
            @attributes[key] = [@attributes[key]] unless @attributes[key].is_a?(Array)
            @attributes[key] << value
          else
            @attributes[key] = value unless key == :compound || @attributes[key]
          end
        end
      else
        @attributes = value_hash.merge(@attributes)
      end
    end
200636
def store_fields

      # class name of the object goes to position 0
      @xapian_doc.add_value 0, @obj.class.name
      # natural sort order goes to position 1
      if @blueprint._natural_sort_order.is_a? Proc
        sort_value = @obj.instance_eval &@blueprint._natural_sort_order
      else
        sort_value = @obj.send @blueprint._natural_sort_order
      end
      @xapian_doc.add_value 1, sort_value.to_s

      @blueprint.attribute_names.each do |attribute|
        block = @blueprint.block_for_attribute attribute
        if block
          value = @obj.instance_eval &block
        else
          value = @obj.send attribute
        end

        codec          = XapianDb::TypeCodec.codec_for @blueprint.type_map[attribute]
        encoded_string = codec.encode value
        @xapian_doc.add_value DocumentBlueprint.value_number_for(attribute), encoded_string unless encoded_string.nil?
      end
    end
1157744
def to_hash
      serialized_attributes = attributes.dup

      self.class.expandable_attributes.each_pair.select do |attribute_name, expanded_class|
        if expanded_class === attributes[attribute_name]
          serialized_attributes[attribute_name] = serialized_attributes[attribute_name].id
        end
      end

      serialized_attributes
    end
1311446
def serializable_hash
      return serializable_collection if collection?
      self.class._attributes.each_with_object({}) do |(name, option), hash|
        if _include_from_options?(name) && public_send(option[:include_method])
          hash[option[:key] || name] = _set_value(name, option)
        end
      end
    end
1169875
def names
      NAME_FIELDS.map { |k| has_field?(k) ? @fields[k].tokens : nil }.flatten.compact
    end
948299
def solr_names_and_values(field_name, field_value, index_types)
      return {} if field_value.nil?
      
      # Determine the set of index types
      index_types = Array(index_types)
      index_types.uniq!
      index_types.dup.each do |index_type|
        if index_type.to_s =~ /^not_(.*)/
          index_types.delete index_type # not_foo
          index_types.delete $1.to_sym  # foo
        end
      end
      
      # Map names and values
      
      results = {}

      # Time seems to extend enumerable, so wrap it so we don't interate over each of its elements.
      field_value = [field_value] if field_value.kind_of? Time
      
      index_types.each do |index_type|
        Array(field_value).each do |single_value|
          # Get mapping for field
          descriptor = indexer(index_type)
          data_type = extract_type(single_value)
          name, converter = descriptor.name_and_converter(field_name, type: data_type)
          next unless name

          # Is there a custom converter?
          # TODO instead of a custom converter, look for input data type and output data type. Create a few methods that can do that cast.

          value = if converter
            if converter.arity == 1
              converter.call(single_value)
            else
              converter.call(single_value, field_name)
            end
          elsif data_type == :boolean
            single_value
          else
            single_value.to_s
          end
          
          # Add mapped name & value, unless it's a duplicate
          if descriptor.evaluate_suffix(data_type).multivalued?
            values = (results[name] ||= [])
            values << value unless value.nil? || values.include?(value)
          else
            Solrizer.logger.warn "Setting #{name} to `#{value}', but it already had `#{results[name]}'" if results[name] && Solrizer.logger
            results[name] = value
          end
        end
      end
        
      results
    end
127608
def attributes(*attributes)
      attributes.each do |attr|
        raise ArgumentError.new("You cannot use #{attr} as an attribute name since it is a reserved method name of Xapian::Document") if reserved_method_name?(attr)
        @attributes_hash[attr] = {}
        @type_map[attr] = :string
        self.index attr
      end
    end
729836
def basic_options
      Hash[BASIC_OPTION_KEYS.map { |k| [k, send(k)] }].reject {|_,v| v.nil?}
    end
811020
def get_hash(node,fields = None,exclude = ['pk','_id'],target = 'pk'):
    

    hasher = Hasher()

    def add_to_hash(value):

        if isinstance(value,dict):
            if target in value:
                add_to_hash(value[target])
            else:
                attribute_list = []
                for key,v in sorted(value.items(),key = lambda x: x[0]):

                    if (fields is not None and key not in fields) \
                        or (exclude is not None and key in exclude):
                        continue
                    add_to_hash(key)
                    add_to_hash(v)
        elif isinstance(value,(tuple,list)) and value and isinstance(value[0],(dict,node_class)):
            for i,v in enumerate(value):
                hasher.add(i)
                add_to_hash(v)
        else:
            hasher.add(value)

    add_to_hash(node)

    return hasher.digest.hexdigest()
522372
def sort_params
      @_sort_params ||=
        if params[:sort].present?
          params[:sort].split(',').each_with_object({}) do |field, hash|
            unformatted_field  = @request.unformat_key(field)
            desc, field        = unformatted_field.to_s.match(/^([-_])?(\w+)$/i)[1..2]
            hash[field.to_sym] = desc.present? ? :desc : :asc
          end
        end
    end
143466
def fields_to_validate
      required_fields = to_hash opts[:required]
      optional_fields = to_hash opts[:optional]
      required_fields.keys.each { |key| required_fields[key][:required] = true }
      optional_fields.merge(required_fields)
    end
329760
def to_hash(args = {}) # :nodoc:
      args ||= {}

      if args[:nested]
        {'url' => self[:@url] || self[:url]}
      else
        hash = super
        hash.merge!('@version' => self['@version']) unless new_record?
        {self.class.json_name => hash}
      end
    end