Sha256: 8e5bcbebef8d986ef6780d33bba64edb9e28b2b9aa77d284643fb797838d2111

Contents?: true

Size: 576 Bytes

Versions: 8

Compression:

Stored size: 576 Bytes

Contents

# to_key method returns a suitable unique id that can be used as
# a react `key`.  Other classes may override to_key as needed
# for example hyper_mesh returns the object id of the internal
# backing record.
#
# to_key is automatically called on objects passed as keys for
# example Foo(key: my_object) results in Foo(key: my_object.to_key)
class Object
  def to_key
    object_id
  end
end

# for Number to_key can just be the number itself
class Number
  def to_key
    self
  end
end

# for Boolean to_key can be true or false
class Boolean
  def to_key
    self
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
hyper-component-0.99.6 lib/react/to_key.rb
hyper-component-0.99.5 lib/react/to_key.rb
hyper-component-0.99.4 lib/react/to_key.rb
hyper-component-0.99.3 lib/react/to_key.rb
hyper-component-0.99.2 lib/react/to_key.rb
hyper-component-0.99.1 lib/react/to_key.rb
hyper-component-0.99.0 lib/react/to_key.rb
hyper-react-1.0.0.lap28 lib/react/to_key.rb