Module: Campo::Helpers
- Defined in:
- lib/campo.rb
Overview
Convenience
Class Method Summary collapse
-
.options_builder(name, opts) ⇒ Object
[ [id, lookup, selected || false], … ].
- .options_outputter(opts = []) ⇒ Object
Class Method Details
.options_builder(name, opts) ⇒ Object
- [id, lookup, selected || false], …
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/campo.rb', line 134 def self.( 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
149 150 151 152 |
# File 'lib/campo.rb', line 149 def self.( opts=[] ) return "" if opts.nil? || opts.empty? opts.map{|o| "#{o.output}\n" }.reduce(:+) end |