Skip to content

Commit

Permalink
Speedup dynamic methods. Closes #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Dion Mendel committed Oct 17, 2016
1 parent 38edfa0 commit 72dec7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.rdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
= BinData Changelog

== Version 2.3.4 (2016-10-17)

* Memoize dynamic methods for primitives. Thanks to hiroeorz.

== Version 2.3.3 (2016-09-07)

* Fix bug #80. Thanks to Michael Petter.
Expand Down
3 changes: 3 additions & 0 deletions lib/bindata/base_primitive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def respond_to?(symbol, include_private = false) #:nodoc:
def method_missing(symbol, *args, &block) #:nodoc:
child = snapshot
if child.respond_to?(symbol)
self.class.class_eval "def #{symbol}(*args, &block);" \
" snapshot.#{symbol}(*args, &block);" \
"end"
child.__send__(symbol, *args, &block)
else
super
Expand Down

0 comments on commit 72dec7e

Please sign in to comment.