Class: MultipleMan::Identity::MultipleField

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, identify_by) ⇒ MultipleField

Returns a new instance of MultipleField.



18
19
20
21
# File 'lib/multiple_man/identity.rb', line 18

def initialize(record, identify_by)
  self.identify_by = identify_by ? [*identify_by] : [:id]
  super(record)
end

Instance Attribute Details

#identify_byObject

Returns the value of attribute identify_by.



28
29
30
# File 'lib/multiple_man/identity.rb', line 28

def identify_by
  @identify_by
end

Instance Method Details

#valueObject



22
23
24
25
26
# File 'lib/multiple_man/identity.rb', line 22

def value
  Hash[identify_by.map do |field|
    [field, record.send(field)]
  end]
end