class JSCObject::Accessor(T)
- JSCObject::Accessor(T)
- Reference
- Object
Overview
An Accessor
represents a JavaScript object's property which is defined via JS Object.defineProperty
An Accessor
can define its own setter or getter via Accessor#get(&block)
and Accessor#set(&block)
.
An Accessor
can have both setter and getter, either, or even none.
require "uuid"
uuid = JSCObject.new
uuid_get_only_accessor = JSCObject::Accessor(String).new name: "random"
uuid.get do
UUID.random
end
uuid.mount_accessor uuid_get_only_accessor
JSCContext.set_value "UUID", uuid
In WebInspector, types UUID.random
Defined in:
components/jsc_object/accessor.crConstructors
-
.new(name : String)
Initializes a new
Accessor
, given it name.
Instance Method Summary
-
#get(&block : -> T)
Specifies
Accessor
's getter -
#set(&block : Proc(JSCFunction | JSCObject | JSCPrimative, Nil))
Specifies
Accessor
's setter.
Constructor Detail
Instance Method Detail
Specifies Accessor
's setter.