Class: AgnosticBackend::Cloudsearch::RemoteIndexField

Inherits:
Object
  • Object
show all
Defined in:
lib/agnostic_backend/cloudsearch/remote_index_field.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_field_struct) ⇒ RemoteIndexField

Returns a new instance of RemoteIndexField.



17
18
19
20
# File 'lib/agnostic_backend/cloudsearch/remote_index_field.rb', line 17

def initialize(remote_field_struct)
  @field = remote_field_struct.options
  @status = remote_field_struct.status
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/agnostic_backend/cloudsearch/remote_index_field.rb', line 22

def method_missing(method_name)
  if field.respond_to?(method_name)
    field.send(method_name)
  else
    super
  end
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/remote_index_field.rb', line 5

def field
  @field
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/agnostic_backend/cloudsearch/remote_index_field.rb', line 5

def status
  @status
end

Class Method Details

.partition(local_fields, remote_fields) ⇒ Object

returns an array with two elements: the first is an array with the remote fields that correspond to local fields the second is an array with the remote that do not have corresponding local fields



10
11
12
13
14
15
# File 'lib/agnostic_backend/cloudsearch/remote_index_field.rb', line 10

def self.partition(local_fields, remote_fields)
  local_field_names = local_fields.map(&:name)
  remote_fields.partition do |remote_field|
    local_field_names.include? remote_field.index_field_name
  end
end