Module: DataMapper::YS::IndexedProperty

Defined in:
lib/dm-ys/indexed_property.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



33
34
35
# File 'lib/dm-ys/indexed_property.rb', line 33

def <=>(other)
  id<=>other.id
end

#[](key) ⇒ Object



29
30
31
# File 'lib/dm-ys/indexed_property.rb', line 29

def [](key)
  attributes[normalized_property_for(key)]
end

#normalized_property_for(key) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dm-ys/indexed_property.rb', line 16

def normalized_property_for(key)
  case key
  when Integer
    properties.map(&:name)[key]
  when String
    key.intern
  when Symbol
    key
  else
    raise InvalidIndex, "expected Integer/String/Symbol, but got #{key.class}"
  end
end