Class: Opinions::KeyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/opinions.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ KeyBuilder

Returns a new instance of KeyBuilder.



21
22
23
24
25
# File 'lib/opinions.rb', line 21

def initialize(args)
  @object  = args.fetch(:object)
  @target  = args.fetch(:target, nil)
  @opinion = args.fetch(:opinion)
end

Instance Method Details

#keyObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/opinions.rb', line 27

def key
  object = @object.dup
  object.class.send(:include, KeyBuilderExtensions)
  key = object.generate_key(@opinion, object.id)
  if @target
    tcn = @target.class == Class ? @target.name : @target.class.name
    key += ":#{tcn}"
  end
  key
end