Sha256: 9f89e041bbaef9a6f33f33c365d67d5e7f68c40024d8d029d53a4df316e96f93

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

module Yaks
  class Resource
    class Form
      include Yaks::Mapper::Form::Config.attributes.remove(:dynamic_blocks)

      def [](name)
        fields.find {|field| field.name.equal? name}.value
      end

      def values
        fields_flat.each_with_object({}) do |field, values|
          values[field.name] = field.value
        end
      end

      def fields_flat(fields = fields)
        fields.each_with_object([]) do |field, acc|
          if field.type.equal? :fieldset
            acc.concat(fields_flat field.fields)
          else
            acc << field
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaks-0.8.0.beta1 lib/yaks/resource/form.rb