refinements Questions

1

Solved

In Metaprogramming Ruby 2 in Chapter 2 at the "Refinements" section I found the following piece of Ruby code: class MyClass def my_method "original my_method()" end def another_method my_m...
Siren asked 7/10, 2017 at 18:30

1

I'm trying to use ruby refinements to apply rails hooks. I want to avoid monkey patching. When monkey patching it would work as such ActiveRecord::Base.class_eval do after_find do # do someth...
Window asked 31/8, 2015 at 16:32

2

I have a Rails 4 project using Ruby 2.0. I've defined some refinements. Putting <% using MyRefinements %> at the top of the view files causes the error "undefined method 'using'". When I...
Andres asked 17/3, 2014 at 19:27

1

Solved

I tried to use a Refinement in IRB (v0.9.6, Ruby 2.3.0): module Foo refine Object do def foo() "foo" end end end using Foo # => RuntimeError: main.using is permitted only at toplevel This...
Accountable asked 5/1, 2016 at 20:21

1

Solved

Let's say I've got refinement module RefinedString refine String do def remove_latin_letters #code code code code end end end and I use it inside my class Speech: class Speech using Refin...
Edlin asked 28/8, 2015 at 17:39

1

Solved

There is a pretty good documentation of the current implementation of refinements in ruby here: http://ruby-doc.org//core-2.2.0/doc/syntax/refinements_rdoc.html, but there are some strange corner c...
Barkley asked 21/2, 2015 at 18:18

2

Module#refine method takes a class and a block and returns a refinement module, so I thought I could define: class Class def include_refined(klass) _refinement = Module.new do include refine(kl...
Sorrows asked 31/8, 2013 at 17:44

2

Solved

I'm trying to understand Ruby's refinements feature, and I've encountered a scenario I don't understand. Take this example code: class Traveller def what_are_you puts "I'm a Backpacker" end ...
Mizuki asked 8/1, 2015 at 5:22

1

Solved

There were so-called refinements introduced in Ruby 2.0. I was playing with them and now I’m totally cajoled: — The main declared advantage of refine is that they are not global scoped. Bah....
Daphene asked 5/3, 2013 at 9:45
1

© 2022 - 2024 — McMap. All rights reserved.