Sha256: aa898aa04ae0a243155da296c50df3e0f2ad01e159d57187f2053e4b61a6f4dc
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module FSM # # Execute an action specified by either String, Sylbol or Proc. # Symbol and String represent methods which are called on the target object, Proc will get executed # and receives at least the target as parameter. If others parameters are passed then they'll get forwarded as well. class Executable # Create a new Executable # if args is true, then arguments are passed on to the target method or the Proc, if false nothing # will get passed def initialize(thing) raise ArgumentError.new("Unknown thing #{thing}") unless thing @thing = thing end # execute this executable on the given target def execute(target, *args) case @thing when String, Symbol if (args.length > 0) target.send(@thing, *args) else target.send(@thing) end when Proc if (args.length > 0) @thing.call(target, *args) else @thing.call(target) end else raise "Unknown Thing #{@thing}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simplificator-fsm-0.3.9 | lib/fsm/executable.rb |