Sha256: 30a4e69e46e8873cb69f390a30aa9d4a83a3dd8bd68d8a3398664cb4c311804c

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

class Object
  # Lazy load HTML tag constants in the form DIV or A
  # This is needed to allow for a tags to be used in expressions like
  # render(DIV) do ...
  # By lazy loading we don't unecessarily create a pile of constant element tags
  # that will probably never get used.

  class Object
    class << self
      alias _reactrb_tag_original_const_missing const_missing

      def const_missing(const_name)
        # Opal uses const_missing to initially define things,
        # so we always call the original, and respond to the exception
        _reactrb_tag_original_const_missing(const_name)
      rescue StandardError => e
        Hyperstack::Internal::Component::Tags.html_tag_class_for(const_name) || raise(e)
      end
    end
  end

  # 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)
  def to_key
    object_id
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyper-component-1.0.alpha1.8 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.7 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.6 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.5 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.4 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.3 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.2 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1.1 lib/hyperstack/ext/component/object.rb
hyper-component-1.0.alpha1 lib/hyperstack/ext/component/object.rb