Sha256: 3d01e4ddda2b384166abb063e3e82aac0a8f2e31dd2812be1ceba7f607d852be

Contents?: true

Size: 849 Bytes

Versions: 47

Compression:

Stored size: 849 Bytes

Contents

module DynamicScaffold
  module Form
    module Item
      class TwoOptions < Base
        def initialize(config, type, *args)
          name = args.shift
          # rubocop:disable Style/IdenticalConditionalBranches
          if args[args.length - 2].is_a?(Hash)
            html_attributes = args.extract_options!
            @options = args.extract_options!
          else
            html_attributes = {}
            @options = args.extract_options!
          end
          # rubocop:enable Style/IdenticalConditionalBranches

          @args = args
          super(config, type, name, html_attributes)
        end

        def render(_view, form, classnames = nil)
          html_attributes = build_html_attributes(classnames)
          form.public_send(@type, @name, *@args, @options, html_attributes)
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
dynamic_scaffold-0.3.0 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.2.0 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.1.4 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.1.3 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.1.2 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.1.1 lib/dynamic_scaffold/form/item/two_options.rb
dynamic_scaffold-0.1.0 lib/dynamic_scaffold/form/item/two_options.rb