Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/h8/value.rb,
lib/h8/context.rb
Overview
Ruby object’s t_ruby does nothing (tree conversion optimization)
Instance Method Summary collapse
-
#__js_enumerate ⇒ Array[String]
Enumerate _own properties_ to access from JS code.
-
#__js_has_property(name) ⇒ Object
JS hasOwnProperty() implementation.
-
#__to_json ⇒ Object
Integration with JSON.stringify in JS.
-
#to_ruby(depth = 0) ⇒ Object
It is already a ruby object.
Instance Method Details
#__js_enumerate ⇒ Array[String]
Enumerate _own properties_ to access from JS code. Think about calling super when overriding it.
76 77 78 79 80 81 82 |
# File 'lib/h8/context.rb', line 76 def __js_enumerate if respond_to?(:keys) self.keys.map(&:to_s) else [] end end |
#__js_has_property(name) ⇒ Object
JS hasOwnProperty() implementation
68 69 70 |
# File 'lib/h8/context.rb', line 68 def __js_has_property name __js_enumerate.include?(name) end |
#__to_json ⇒ Object
Integration with JSON.stringify in JS. Method should return valid JSON _string representation_. Works using standard ruby JSON or Rails ties. Usually you do not override it but implement #to_json or, in Rails, #as_json *args. But in some cases you might need to implement it directly
63 64 65 |
# File 'lib/h8/context.rb', line 63 def __to_json JSON.unparse self end |
#to_ruby(depth = 0) ⇒ Object
It is already a ruby object. Gate objects should override as need
223 224 225 |
# File 'lib/h8/value.rb', line 223 def to_ruby depth=0 self end |