Class: Solr::CoreConfiguration::CoreConfigBuilder
- Inherits:
-
Object
- Object
- Solr::CoreConfiguration::CoreConfigBuilder
- Defined in:
- lib/solr/core_configuration/core_config_builder.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#dynamic_fields ⇒ Object
readonly
Returns the value of attribute dynamic_fields.
-
#fields_params ⇒ Object
readonly
Returns the value of attribute fields_params.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #build ⇒ Object
- #dynamic_field(field_name, solr_name:) ⇒ Object
- #field(field_name, params = {}) ⇒ Object
- #get_dynamic_field(field_name, dynamic_field_name) ⇒ Object
-
#initialize(name:, default:) ⇒ CoreConfigBuilder
constructor
A new instance of CoreConfigBuilder.
Constructor Details
#initialize(name:, default:) ⇒ CoreConfigBuilder
Returns a new instance of CoreConfigBuilder.
6 7 8 9 10 11 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 6 def initialize(name:, default:) @name = name @default = default @dynamic_fields = {} @fields_params = {} end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
4 5 6 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 4 def default @default end |
#dynamic_fields ⇒ Object (readonly)
Returns the value of attribute dynamic_fields.
4 5 6 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 4 def dynamic_fields @dynamic_fields end |
#fields_params ⇒ Object (readonly)
Returns the value of attribute fields_params.
4 5 6 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 4 def fields_params @fields_params end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 4 def name @name end |
Instance Method Details
#build ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 21 def build Solr::CoreConfiguration::CoreConfig.new( name: name, fields: build_fields, default: default ) end |
#dynamic_field(field_name, solr_name:) ⇒ Object
13 14 15 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 13 def dynamic_field(field_name, solr_name:) dynamic_fields[field_name] = Solr::CoreConfiguration::DynamicField.new(name: field_name, solr_name: solr_name) end |
#field(field_name, params = {}) ⇒ Object
17 18 19 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 17 def field(field_name, params = {}) fields_params[field_name] = params end |
#get_dynamic_field(field_name, dynamic_field_name) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/solr/core_configuration/core_config_builder.rb', line 29 def get_dynamic_field(field_name, dynamic_field_name) dynamic_field = dynamic_fields[dynamic_field_name] if dynamic_field_name && !dynamic_field raise "Field '#{field_name}' is mapped to an undefined dynamic field '#{dynamic_field_name}'" end dynamic_field end |