[#83096] File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?}) — Nobuyoshi Nakada <nobu@...>
On 2017/10/04 8:47, normal@ruby-lang.org wrote:
5 messages
2017/10/04
[#83100] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Eric Wong <normalperson@...>
2017/10/04
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#83105] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Nobuyoshi Nakada <nobu@...>
2017/10/04
On 2017/10/04 15:55, Eric Wong wrote:
[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>
Hello,
9 messages
2017/10/04
[#83113] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/05
This has been requested countless times, then rejected each and every time.
[#83129] Re: Alias Enumerable#include? to Enumerable#includes?
— Alberto Almagro <albertoalmagro@...>
2017/10/05
Sorry I didn't found it on the core mail list's archive.
[#83138] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/06
Ruby has not been made of popular votes so far. You have to show us
[#83149] Re: Alias Enumerable#include? to Enumerable#includes?
— Eric Wong <normalperson@...>
2017/10/06
Alberto Almagro <albertoalmagro@gmail.com> wrote:
[#83200] [Ruby trunk Feature#13996] [PATCH] file.c: apply2files releases GVL — normalperson@...
Issue #13996 has been reported by normalperson (Eric Wong).
4 messages
2017/10/10
[ruby-core:83585] [Ruby trunk Feature#14059] Refine multiple classes in one call
From:
duerst@...
Date:
2017-10-26 23:13:19 UTC
List:
ruby-core #83585
Issue #14059 has been updated by duerst (Martin D端rst).
I'm really not sure about this. If we need this for refinements, why don't we have for classes in the first place? E.g.:
```ruby
class Foo, Bar, Baz
def positive_integer?
false
end
end
```
It seems strange to introduce syntactic sugar just for refinements.
----------------------------------------
Feature #14059: Refine multiple classes in one call
https://bugs.ruby-lang.org/issues/14059#change-67611
* Author: kddeisz (Kevin Deisz)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Consider the following problem - I would like to be able to validate that a JSON string contains all things that can represent positive integers. In this case, it works well with refinements, because I can:
~~~
class PositiveJSONValidator < ActiveModel::EachValidator
using Module.new {
refine String do
def positive_integer?
match?(/[1-9](?:[0-9])*/)
end
end
refine Integer do
def positive_integer?
self > 0
end
end
refine Float do
def positive_integer?
self == self.to_i
end
end
refine NilClass do
def positive_integer?
false
end
end
refine Array do
def positive_integer?
false
end
end
refine Hash do
def positive_integer?
false
end
end
}
def validate_each(record, attribute, value)
return if valid_positive_json?(value)
record.errors[attribute] << options[:message] || 'is invalid'
end
private
def valid_positive_json?(value)
JSON.parse(value).all? do |key, value|
key.positive_integer? && value.positive_integer?
end
rescue JSON::ParserError
false
end
end
~~~
However, this is kind of annoying because I need to specify each class manually. What I'd love to be able to do is group classes by passing all of the ones that need to be refined in the same way, as in:
~~~
refine NilClass, Array, Hash do
def positive_integer?
false
end
end
~~~
Is this something that people would consider? It seems like a good use case for refinements because I just want to send a message to an object, so basically I want a default case. I could just refine Object but that feels wrong, I'd rather get an undefined method exception so that I know something unexpected occurred. If accepted I'd be happy to submit a patch.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>