Questions tagged [ruby-2.2]

For issues relating to development in Ruby, version 2.2. If your question applies to Ruby in general, use the tag [tag:ruby].

For issues relating to development in Ruby, version 2.2. It was released on December 2014. You can check the official docs here.

If your question applies to Ruby in general, use the tag .

119 questions
30
votes
3 answers

AWS Elastic Beanstalk - How To Upgrade Existing Environment from Ruby 2.1 to Ruby 2.2

AWS Elastic Beanstalk - Cannot Clone With Latest Platform or eb upgrade from Ruby 2.1 to Ruby 2.2 I've been smashing my head on this one. Back in May, AWS announced that their Ruby Elastic Environments now offer Ruby-2.2 (e.g.…
Dan
  • 1,955
  • 17
  • 21
17
votes
2 answers

How to construct URI with query arguments from hash in Ruby

How to construct URI object with query arguments by passing hash? I can generate query with: URI::HTTPS.build(host: 'example.com', query: "a=#{hash[:a]}, b=#{[hash:b]}") which generates https://example.com?a=argument1&b=argument2 however I think…
Filip Bartuzi
  • 5,711
  • 7
  • 54
  • 102
14
votes
3 answers

Celluloid async inside ruby blocks does not work

Trying to implement Celluloid async on my working example seem to exhibit weird behavior. here my code looks class Indefinite include Celluloid def run! loop do [1].each do |i| async.on_background …
Viren
  • 5,812
  • 6
  • 45
  • 98
13
votes
3 answers

Keyword arguments unpacking (splat) in Ruby

What is happening below seems a little strange to me. def f(a, b) puts "#{a} :: #{b}" end f(*[1, 2], **{}) # prints "1 :: 2" hash = {} f(*[1, 2], **hash) ArgumentError: wrong number of arguments (3 for 2) f(*[1, 2], **Hash.new) ArgumentError:…
Vlad M
  • 477
  • 3
  • 10
12
votes
2 answers

DateTime subtraction in ruby 2?

I need to subtract two DateTime objects in order to find out the difference in hours between them. I try to do the following: a = DateTime.new(2015, 6, 20, 16) b = DateTime.new(2015, 6, 21, 16) puts a - b I get (-1/1), the object of class…
Denis Yakovenko
  • 3,241
  • 6
  • 48
  • 82
11
votes
1 answer

Singleton can't be dumped - cached_resource gem

Using cached_resource gem for caching active resources. User model class User < ActiveResource::Base cached_resource class teachers < SimpleDelegator attr_accessor :teacher_id def initialize(attributes = {}, _persisted = true) …
10
votes
1 answer

Garbage Collection of Symbols Ruby 2.2.1

So garbage collection of symbols has been introduced from Ruby 2.2+ version. I wrote the following the code snippet in irb : before = Symbol.all_symbols.size #=>3331 100_000.times do |i| "sym#{i}".to_sym end Symbol.all_symbols.size #=>…
mhaseeb
  • 1,739
  • 2
  • 12
  • 24
10
votes
2 answers

How to refine module method in Ruby?

You can refine your class with module RefinedString refine String do def to_boolean(text) !!(text =~ /^(true|t|yes|y|1)$/i) end end end but how to refine module method? This: module RefinedMath refine Math do def PI …
Filip Bartuzi
  • 5,711
  • 7
  • 54
  • 102
6
votes
0 answers

Why does Rails 5 edge version API-only app includes Sprockets and SAAS in Gemfile?

I have generated a skeleton-API-only app based on Rails 5 edge version using command: rails app_name --api --edge Its Gemfile includes Sprockets and SASS gems as can be seen in it. gem 'sprockets-rails', github: "rails/sprockets-rails" gem…
Jignesh Gohel
  • 6,236
  • 6
  • 53
  • 89
6
votes
4 answers

Ruby HTTParty - get the redirected URL

I am trying to send an HTTP request using HTTParty with some parameters, Eg: GET URL: http://example1.com?a=123&b=456 response_to_get = HTTParty.get('http://example1.com?a=123&b=456') The redirect_url for this particular request is…
6
votes
1 answer

Rails 4, RSpec 3.2 - how to mockup ActionMailer's deliver_now method to raise exceptions

Environment Ruby 2.2.1, Rails 4.2.0, rspec-core 3.2.2, rspec-expectations 3.2.0, rspec-mocks 3.2.1, rspec-rails 3.2.1, rspec-support 3.2.2 I have the following method def send_event_alert_email(event_id) event = Event.find_by(id: event_id) ... …
Jignesh Gohel
  • 6,236
  • 6
  • 53
  • 89
6
votes
1 answer

Error installing Ruby 2.2.2 with RVM on Ubuntu 14.04

Here's what. I first did: rvm get stable rvm install ruby-2.2.2 No deal. It shows me the following: $ rvm install ruby-2.2.2 Searching for binary rubies, this might take some time. No binary rubies available for:…
Mauricio Moraes
  • 7,255
  • 5
  • 39
  • 59
5
votes
2 answers

Why doesn't Ruby find classes in a higher scope when module is specified using ::?

I just got stuck on this for a while. Take this base: module Top class Test end module Foo end end Later, I can define classes inside Foo that extends Test by doing this: module Top module Foo class SomeTest < Test end …
Hubro
  • 56,214
  • 69
  • 228
  • 381
5
votes
2 answers

Is { 'symbol name': "some value" } valid Ruby 2 syntax for Hashes?

TL;DR — The Question Is { 'symbol name': 5 } and { "symbol name": 5 } valid and well-defined Ruby 2 syntax for Hashes? 6 Notations for Hashes, 2 of them yet unknown In Ruby 2, the following Hash literal notations are equivalent: { :my_key => 5 } {…
das-g
  • 9,718
  • 4
  • 38
  • 80
5
votes
2 answers

How do I add named parameters in a subclass or change their default in Ruby 2.2?

This question is about Ruby 2.2. Let's say I have a method which takes positional and named arguments. class Parent def foo(positional, named1: "parent", named2: "parent") puts positional.inspect puts named1.inspect puts…
Schwern
  • 153,029
  • 25
  • 195
  • 336
1
2 3 4 5 6 7 8