Class: Esse::IndexMapping
- Inherits:
 - 
      Object
      
        
- Object
 - Esse::IndexMapping
 
 
- Defined in:
 - lib/esse/index_mapping.rb
 
Constant Summary collapse
- FILENAMES =
 %w[mapping mappings].freeze
Instance Method Summary collapse
- #body ⇒ Object
 - #empty? ⇒ Boolean
 - 
  
    
      #initialize(body: {}, paths: [], filenames: FILENAMES, globals: nil)  ⇒ IndexMapping 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of IndexMapping.
 - 
  
    
      #to_h  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
This method will be overwrited when passing a block during the mapping defination.
 
Constructor Details
#initialize(body: {}, paths: [], filenames: FILENAMES, globals: nil) ⇒ IndexMapping
Returns a new instance of IndexMapping.
      7 8 9 10 11 12  | 
    
      # File 'lib/esse/index_mapping.rb', line 7 def initialize(body: {}, paths: [], filenames: FILENAMES, globals: nil) @paths = Array(paths) @filenames = Array(filenames) @mappings = body @globals = globals || -> { {} } end  | 
  
Instance Method Details
#body ⇒ Object
      22 23 24 25 26 27 28 29 30 31  | 
    
      # File 'lib/esse/index_mapping.rb', line 22 def body global = HashUtils.deep_transform_keys(@globals.call, &:to_sym) local = HashUtils.deep_transform_keys(to_h.dup, &:to_sym) dynamic_template = DynamicTemplate.new(global[:dynamic_templates]) dynamic_template.merge!(local.delete(:dynamic_templates)) if dynamic_template.any? global[:dynamic_templates] = dynamic_template.to_a end HashUtils.deep_merge(global, local) end  | 
  
#empty? ⇒ Boolean
      33 34 35  | 
    
      # File 'lib/esse/index_mapping.rb', line 33 def empty? body.empty? end  | 
  
#to_h ⇒ Object
This method will be overwrited when passing a block during the mapping defination
      16 17 18 19 20  | 
    
      # File 'lib/esse/index_mapping.rb', line 16 def to_h return @mappings unless @mappings.empty? from_template || @mappings end  |