Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",
class Array | |
# find_map | |
# example: | |
# [nil, 'hello '].find_map |n| | |
# n.try(:strip) | |
# end => 'hello' | |
def find_map(&block) | |
result = nil | |
self.each do |q| | |
result = yield(q) |
# && | |
'hello' unless true && false | |
#=> "hello" | |
'hello' unless false && true | |
#=> "hello" | |
'hello' unless false && false | |
#=> "hello" | |
'hello' unless true && true | |
#=> nil |
class Hash | |
# merge_present | |
# examples: | |
# {hello: ''}.merge_present(hello: 'sd') #=> {hello: 'sd'} | |
# | |
# {hello: nil}.merge_present(hello: '') #=> {} | |
# | |
def merge_present(other_hash) | |
mapped = self.map do |k, v| | |
if v.blank? |
Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",
if("hello") "hello"; | |
"hello" | |
if(0) "hello"; | |
undefined | |
if('') "hello"; | |
undefined | |
if(1) "hello"; | |
"hello" |
def specific_enqueued_jobs(job) | |
enqueued_jobs.select{ |j| j if j[:job] == job } | |
end | |
require 'active_support/core_ext/class/subclasses' | |
require 'active_support/core_ext/hash/keys' | |
module ActiveJob | |
# Provides helper methods for testing Active Job | |
module RSpecHelper | |
extend ActiveSupport::Concern |