Sha256: 1b40fa3a710a3ed09d5e78c0dd5ee72ca754d6bb9d8e650c64ba02133074d6b3
Contents?: true
Size: 605 Bytes
Versions: 20
Compression:
Stored size: 605 Bytes
Contents
module WithRandomizations extend ActiveSupport::Concern included do serialize :randomizations, Hash end def seed @seed || 0 end def seed_with!(seed) @seed = seed end def randomizer @randomizer ||= Mumukit::Randomizer.parse(randomizations) end module ClassMethods def randomize(*selectors) selectors.each { |selector| randomize_field selector } end private def randomize_field(selector) define_method(selector) do |*args| return unless super(*args) randomizer.randomize!(super(*args), seed) end end end end
Version data entries
20 entries across 20 versions & 2 rubygems