Class: ActiveFedora::Indexing::Map::IndexObject

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/indexing/map.rb

Overview

this enables a cleaner API for solr integration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, behaviors: []) {|_self| ... } ⇒ IndexObject

Returns a new instance of IndexObject.

Yields:

  • (_self)

Yield Parameters:



30
31
32
33
34
35
# File 'lib/active_fedora/indexing/map.rb', line 30

def initialize(name, behaviors: [], &_block)
  @behaviors = behaviors
  @data_type = :string
  @key = name
  yield self if block_given?
end

Instance Attribute Details

#behaviorsObject

Returns the value of attribute behaviors.



27
28
29
# File 'lib/active_fedora/indexing/map.rb', line 27

def behaviors
  @behaviors
end

#data_typeObject

Returns the value of attribute data_type.



27
28
29
# File 'lib/active_fedora/indexing/map.rb', line 27

def data_type
  @data_type
end

#keyObject (readonly)

Returns the value of attribute key.



28
29
30
# File 'lib/active_fedora/indexing/map.rb', line 28

def key
  @key
end

#termObject

Returns the value of attribute term.



27
28
29
# File 'lib/active_fedora/indexing/map.rb', line 27

def term
  @term
end

Instance Method Details

#as(*args) ⇒ Object



37
38
39
40
# File 'lib/active_fedora/indexing/map.rb', line 37

def as(*args)
  @term = args.last.is_a?(Hash) ? args.pop : {}
  @behaviors = args
end

#dupObject



46
47
48
49
50
# File 'lib/active_fedora/indexing/map.rb', line 46

def dup
  self.class.new(@key) do |idx|
    idx.behaviors = @behaviors.dup
  end
end

#type(sym) ⇒ Object



42
43
44
# File 'lib/active_fedora/indexing/map.rb', line 42

def type(sym)
  @data_type = sym
end