Sha256: 3d6a27ac962dd2fb60a2e0e9aa4fc28ba63c1196ed59cff31208683bb0054f71

Contents?: true

Size: 590 Bytes

Versions: 30

Compression:

Stored size: 590 Bytes

Contents

module Lolita
  module Configuration
    module Field
      class Enum < Lolita::Configuration::Field::Base

        def values value=nil, &block
          @values=value || block if value || block_given?
          @values
        end

        def view_values(view)
          record = view.send(:current_form).object
          if values.respond_to?(:call)
            values.call(view)
          else
            values || default_values
          end
        end

        private

        def default_values
          dbi_field.limit || [] rescue []
        end

      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
lolita-3.3.6 lib/lolita/configuration/field/enum.rb
lolita-3.3.5 lib/lolita/configuration/field/enum.rb
lolita-3.3.4 lib/lolita/configuration/field/enum.rb
lolita-3.3.3 lib/lolita/configuration/field/enum.rb
lolita-3.3.2 lib/lolita/configuration/field/enum.rb
lolita-3.3.1 lib/lolita/configuration/field/enum.rb
lolita-3.3.0 lib/lolita/configuration/field/enum.rb
lolita-3.2.1 lib/lolita/configuration/field/enum.rb
lolita-3.2.0.rc.17 lib/lolita/configuration/field/enum.rb
lolita-3.2.0.rc.16 lib/lolita/configuration/field/enum.rb