Module: AuxiliaryAddons::RubyAddons

Defined in:
lib/auxiliary_addons/ruby_addons.rb

Instance Method Summary collapse

Instance Method Details

#cast_ids_to_i(params) ⇒ Object

Convert params to arrary of ids



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/auxiliary_addons/ruby_addons.rb', line 28

def cast_ids_to_i(params)
  ids = []
  ids << params["id"].to_i if !params["id"].nil?
  if !params["ids"].nil?
    params["ids"].each do |id|
      next if id.to_i == 0 # Special case: all selected
      ids << id.to_i
    end
  end
  ids
end

#is_array_items_here?(array1, array2, array3) ⇒ Boolean

TODO: make paramters as hash articles Check present not empty of string

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/auxiliary_addons/ruby_addons.rb', line 20

def is_array_items_here?(array1, array2, array3)
  return true if array1.size() > 0
  return true if array2.size() > 0
  return true if array3.size() > 0
  return false
end

#is_object_here?(obj) ⇒ Boolean

Check present of object

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/auxiliary_addons/ruby_addons.rb', line 6

def is_object_here?(obj)
  return false if obj.nil?
  return true
end

#is_string_here?(str) ⇒ Boolean

Check present not empty of string

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/auxiliary_addons/ruby_addons.rb', line 12

def is_string_here?(str)
  return false if str.nil?
  return false if str.blank?
  return true
end