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" |
Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",
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? |
# && | |
'hello' unless true && false | |
#=> "hello" | |
'hello' unless false && true | |
#=> "hello" | |
'hello' unless false && false | |
#=> "hello" | |
'hello' unless true && true | |
#=> nil |
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) |
# In not working!! | |
# Validations are added, but errors are not in the errors list after valid | |
module AddChildValidations | |
extend ActiveSupport::Concern | |
class_methods do | |
# Example: | |
# class User < ActiveRecord::Base | |
# has_one :address | |
# add_child_validations_for :address do |
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 |
############################################# | |
# Push de la rama actual | |
git push origin $rama_actual | |
############################################# | |
# Volver a un commit anterior, descartando los cambios | |
git reset --HARD $SHA1 | |
############################################# | |
# Ver y descargar Ramas remotas |
module SkippableCallbacks | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def _skippable_callbacks | |
[ | |
:after_initialize, | |
:after_build, | |
:before_validation, | |
:after_validation, | |
:before_create, |
# spec/rails_helper.rb | |
# add to your rails_helper inside the | |
RSpec.configure do |config| | |
config.around(:each, type: :request) do |example| | |
Warden.test_mode! | |
example.run | |
Warden.test_reset! | |
end | |
end |