Sha256: 9e73e745c3610f47acb66b97753649840042d3f296f5b363a1dc13d02d97511e

Contents?: true

Size: 750 Bytes

Versions: 4

Compression:

Stored size: 750 Bytes

Contents

module Yaks
  class Mapper
    class Form
      class Field
        # <option>, as used in a <select>
        class Option
          include Attribs.new(:value, :label, selected: false, disabled: false, if: nil)

          def self.create(value, opts)
            new(opts.merge(value: value))
          end

          def to_resource_field_option(mapper)
            return unless self.if.nil? || mapper.expand_value(self.if)

            Resource::Form::Field::Option.new(
              value: mapper.expand_value(value),
              label: mapper.expand_value(label),
              selected: mapper.expand_value(selected),
              disabled: mapper.expand_value(disabled)
            )
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yaks-0.13.0 lib/yaks/mapper/form/field/option.rb
yaks-0.12.0 lib/yaks/mapper/form/field/option.rb
yaks-0.11.0 lib/yaks/mapper/form/field/option.rb
yaks-0.10.0 lib/yaks/mapper/form/field/option.rb