Module: Campo::Helpers

Defined in:
lib/campo/campo.rb

Class Method Summary collapse

Class Method Details

.options_builder(name, opts) ⇒ Object

[id, lookup, selected || false], …


198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/campo/campo.rb', line 198

def self.options_builder( name, opts )
  return [] if opts.nil? || opts.empty?
  
  if opts.respond_to? :each_pair
    opts.map do |id, (inner, selected, atts)|
      Campo::Option.new( name, id, inner, selected, atts )
    end
  else
    opts.map do |id, inner, selected, atts|
      Campo::Option.new( name, id, inner, selected, atts )
    end
  end
end

.options_outputter(opts = []) ⇒ Object



213
214
215
216
# File 'lib/campo/campo.rb', line 213

def self.options_outputter( opts=[] )
  return "" if opts.nil? || opts.empty?
  opts.map{|o| "#{o.output}\n" }.reduce(:+)
end