Class: SimpleSolrClient::Schema::CopyField

Inherits:
Object
  • Object
show all
Includes:
Matcher
Defined in:
lib/simple_solr_client/schema/copyfield.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Matcher

#derive_matcher, #matches

Constructor Details

#initialize(source, dest) ⇒ CopyField

Returns a new instance of CopyField.



8
9
10
11
12
13
# File 'lib/simple_solr_client/schema/copyfield.rb', line 8

def initialize(source, dest)
  self.source   = source
  @dest         = dest
  @matcher      = derive_matcher(source)
  @dest_matcher = derive_matcher(dest)
end

Instance Attribute Details

#destObject

Returns the value of attribute dest.



6
7
8
# File 'lib/simple_solr_client/schema/copyfield.rb', line 6

def dest
  @dest
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/simple_solr_client/schema/copyfield.rb', line 6

def source
  @source
end

Instance Method Details

#dynamic_name(s) ⇒ Object

What name will we get from a matching thing?



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/simple_solr_client/schema/copyfield.rb', line 16

def dynamic_name(s)
  return @dest unless @dest =~ /\*/

  m = @matcher.match(s)
  if m
    prefix = m[1]
    return @dest.sub(/\*/, prefix)
  end
  nil

end

#to_xml_node(doc = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/simple_solr_client/schema/copyfield.rb', line 33

def to_xml_node(doc = nil)
  doc          ||= Nokogiri::XML::Document.new
  cf           = Nokogiri::XML::Element.new('copyField', doc)
  cf['source'] = source
  cf['dest']   = dest
  cf
end