Class: MultipleMan::Identity::SingleField

Inherits:
MultipleMan::Identity show all
Defined in:
lib/multiple_man/identity.rb

Instance Attribute Summary collapse

Attributes inherited from MultipleMan::Identity

#record

Instance Method Summary collapse

Methods inherited from MultipleMan::Identity

build

Constructor Details

#initialize(record, identifier = :id) ⇒ SingleField

Returns a new instance of SingleField.



32
33
34
35
36
# File 'lib/multiple_man/identity.rb', line 32

def initialize(record, identifier = :id)
  MultipleMan.logger.warn("Using :identifier in publish is deprecated, please switch to identify_by.")
  self.identifier = identifier || :id
  super(record)
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



46
47
48
# File 'lib/multiple_man/identity.rb', line 46

def identifier
  @identifier
end

Instance Method Details

#valueObject



38
39
40
41
42
43
44
# File 'lib/multiple_man/identity.rb', line 38

def value
  if identifier.class == Proc
    identifier.call(record).to_s
  else
    record.send(identifier).to_s
  end
end