Class: Propr::Property
Class Method Summary collapse
Class Method Details
.new(name, body) ⇒ Proc
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/propr/property.rb', line 4 def self.new(name, body) body.instance_variable_set(:@name, name) # @return [String] body.define_singleton_method(:name) { @name } # @return [Boolean] body.define_singleton_method(:check) do |*args, &block| if block.nil? true == call(*args) else count = args.first || 100 count.times.all? { true == call(*block.call) } end end body end |