Class: Enquo::Root

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(key) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/enquo/root.rb', line 3

def self.new(key)
	case key
	when RootKey::Static
		_new_from_static_root_key(key)
	else
		raise ArgumentError, "key must be a root key provider object (got a #{key.class})"
	end.tap do |k|
		# DIRTY HACK ALERT: take a reference to the key so it doesn't get GC'd
		# If someone can come up with a better way to acheive this, I'm all ears
		k.instance_variable_set(:@_key, key)
	end
end

Instance Method Details

#field(relation, name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/enquo/root.rb', line 16

def field(relation, name)
	if relation.is_a?(Symbol)
		relation = relation.to_s
	end

	if name.is_a?(Symbol)
		name = name.to_s
	end

	_field(relation, name)
end