52: def initialize(indirection_name, method, key_or_instance, options_or_instance = {})
53: if options_or_instance.is_a? Hash
54: options = options_or_instance
55: @instance = nil
56: else
57: options = {}
58: @instance = options_or_instance
59: end
60:
61: self.indirection_name = indirection_name
62: self.method = method
63:
64: set_attributes(options)
65:
66: @options = options.inject({}) { |hash, ary| hash[ary[0].to_sym] = ary[1]; hash }
67:
68: if key_or_instance.is_a?(String) || key_or_instance.is_a?(Symbol)
69: key = key_or_instance
70: else
71: @instance ||= key_or_instance
72: end
73:
74: if key
75:
76:
77:
78:
79: if key.to_s =~ /^\w+:\/\//
80: set_uri_key(key)
81: else
82: @key = key
83: end
84: end
85:
86: @key = @instance.name if ! @key and @instance
87: end