Module: Nydp::AutoWrap
- Included in:
- Struct
- Defined in:
- lib/nydp/helper.rb
Instance Method Summary collapse
- #_nydp_get(key) ⇒ Object
- #_nydp_ok?(method) ⇒ Boolean
-
#_nydp_procify?(method) ⇒ Boolean
override to allow returning Method instances for given method name.
- #_nydp_safe_send(meth, *args) ⇒ Object
-
#_nydp_wrapper ⇒ Object
include this and be sure to either override #_nydp_ok? or #_nydp_whitelist #_nydp_whitelist should return a list of accessor (zero-arg) methods which are safe for nydp to invoke #_nydp_procify should return a list of methods that can be exposed to script code.
- #to_ruby ⇒ Object
Instance Method Details
#_nydp_get(key) ⇒ Object
25 |
# File 'lib/nydp/helper.rb', line 25 def _nydp_get key ; _nydp_safe_send(key.to_s.as_method_name) ; end |
#_nydp_ok?(method) ⇒ Boolean
23 |
# File 'lib/nydp/helper.rb', line 23 def _nydp_ok? method ; _nydp_whitelist.include? method ; end |
#_nydp_procify?(method) ⇒ Boolean
override to allow returning Method instances for given method name
24 |
# File 'lib/nydp/helper.rb', line 24 def _nydp_procify? method ; _nydp_procs.include? method ; end |
#_nydp_safe_send(meth, *args) ⇒ Object
27 28 29 30 |
# File 'lib/nydp/helper.rb', line 27 def _nydp_safe_send meth, *args return send meth, *args if _nydp_ok?(meth) return method(meth) if _nydp_procify?(meth) end |
#_nydp_wrapper ⇒ Object
include this and be sure to either override #_nydp_ok? or #_nydp_whitelist #_nydp_whitelist should return a list of accessor (zero-arg) methods which are safe for nydp to invoke #_nydp_procify should return a list of methods that can be exposed to script code.
class Blub
_nydp_procs << :blubme
def blubme where, when
puts "blubme #{where}, #{when}"
end
end
in nydp, if blub is an instance of Blub:
(blub.blubme “here” “now”)
prints
blubme here, now
22 |
# File 'lib/nydp/helper.rb', line 22 def _nydp_wrapper ; self ; end |
#to_ruby ⇒ Object
26 |
# File 'lib/nydp/helper.rb', line 26 def to_ruby ; self ; end |