Sha256: 8b283dc377c9cce825fb50eefa91b3b68b18f0c811b736944f94b3e814207eae

Contents?: true

Size: 687 Bytes

Versions: 3

Compression:

Stored size: 687 Bytes

Contents

require 'clevic/delegates/combo_delegate.rb'

module Clevic

# A Combo box which allows a set of values. May or may not
# be restricted to the set.
# TODO this should be a module
class SetDelegate
  # options must contain a :set => [ ... ] to specify the set of values.
  def initialize( field )
    raise "SetDelegate must have a :set in options" if field.set.nil?
    super
  end
  
  def needs_combo?
    true
  end
  
  def restricted?
    field.restricted || false
  end
  
  # Items here could either be single values,
  # or two-value arrays (from a hash-like set), so use key as db value
  # and value as display value
  def population
    field.set_for( entity )
  end
end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clevic-0.13.0.b9 lib/clevic/delegates/set_delegate.rb
clevic-0.13.0.b6 lib/clevic/delegates/set_delegate.rb
clevic-0.13.0.b5 lib/clevic/delegates/set_delegate.rb