[#50466] [ruby-trunk - Bug #7492][Open] Segmentation fault at DL::TestDL#test_call_double on x64 Windows 8 — "phasis68 (Heesob Park)" <phasis@...>

23 messages 2012/12/02

[#50558] [ruby-trunk - Feature #7511][Open] short-circuiting logical implication operator — "rits (First Last)" <redmine@...>

12 messages 2012/12/04

[#50575] [ruby-trunk - Feature #7517][Open] Fixnum::MIN,MAX — "matz (Yukihiro Matsumoto)" <matz@...>

20 messages 2012/12/05

[#50755] Becoming a committer — Charlie Somerville <charlie@...>

Hi ruby-core,

21 messages 2012/12/11
[#50759] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50784] Re: Becoming a committer — Charles Oliver Nutter <headius@...> 2012/12/11

It's really this easy? If so, I'll send over my public key today :)

[#50795] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50806] [ruby-trunk - Feature #7548][Open] Load and Require Callbacks — "trans (Thomas Sawyer)" <transfire@...>

12 messages 2012/12/12

[#50810] [ruby-trunk - Feature #7549][Open] A Ruby Design Process — "brixen (Brian Ford)" <brixen@...>

34 messages 2012/12/12

[#50867] [ruby-trunk - Bug #7556][Assigned] test error on refinement — "usa (Usaku NAKAMURA)" <usa@...>

14 messages 2012/12/13

[#50900] [ruby-trunk - Bug #7564][Open] r38175 introduces incompatibility — "tenderlovemaking (Aaron Patterson)" <aaron@...>

14 messages 2012/12/14

[#50951] [ruby-trunk - Bug #7584][Open] Ruby hangs when shutting down an ssl connection in gc finalization — "bpot (Bob Potter)" <bobby.potter@...>

12 messages 2012/12/17

[#51076] [ruby-trunk - Feature #7604][Open] Make === comparison operator ability to delegate comparison to an argument — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>

12 messages 2012/12/22

[#51170] [ruby-trunk - Bug #7629][Open] Segmentation fault — "atd (Antonio Tapiador)" <atapiador@...>

13 messages 2012/12/28

[ruby-core:50678] Re: [ruby-trunk - Feature #4085] Refinements and nested methods

From: The 8472 <the8472@...>
Date: 2012-12-07 20:28:07 UTC
List: ruby-core #50678
On 07.12.2012 21:02, rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
>
> Issue #4085 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).
>
>
> Aaron, I see your point but often my queries are much more complex than a single mention to some column. So if I have to repeat an unrepresentable column multiple times I'd prefer the block approach.
>
> When I mentioned the DSL issues I did it from my previous experience with Grails. In Grails you can bind the params arguments as the controller's method's arguments. So, consider this:
>
> class SomeController {
>    def someAction(String name) {
>      MyDomainClass.find { name == name} // WTF?! I want to compare the "name" column to the value of the "name" param
>    }
> }
>
> I know this isn't possible in Ruby (the params binding feature). But what if you want to compare "name" column to the result of a call to the "name" local (or inherited) method?

Named parameters? Depends. If you can splat them I would simply suggest 
moving the thing to a different method which won't suffer from scoping 
issues. But really, that's a Groovy-issue in so far that it gives local 
variable names (method argument names essentially are local vars) a 
non-local significance which robs you of the freedom of renaming them as 
you desire without breaking code.

But there are solutions. Remember that it's instance_eval'd:

     MyDomainClass.find { self.name == name}

Alternatively you can teach the DSL some smartness and switch between 
call and instance_eval based on arity:

     MyDomainClass.find {|d| d.name == name}


There are many ways to solve this problem without polluting any external 
object.

>  So if I have to repeat an unrepresentable column multiple times I'd prefer the block approach.

Block approach is a bad name for this, since both approaches are using 
blocks ;) Anyway, this problem can be solved too:

    Foo.dsl do
      col = __send__("illegal_name")
      col.eq(coalesce(id,title)) | col.like("%bar%")
    end

In fact, squeel provides an even more elegant solution. Since column 
names often are escaped with the ` character and that's a valid method 
name in ruby it provides literals that way:

    MyModel.where{other_table.`literal_name` == "bar"}


You're really bringing up edge cases here for which there are multiple 
solutions. There is no necessity to monkey-patch Symbol only to build 
some DSLs, really.

In This Thread

Prev Next