Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",
# 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 |
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" |