Sha256: 47f46c0bee8522294d8203a2e90f034c1380fad308a3967e86fafbc1256610a8

Contents?: true

Size: 811 Bytes

Versions: 12

Compression:

Stored size: 811 Bytes

Contents

module SimpleForm
  module Components
    # Needs to be enabled in order to do automatic lookups.
    module Pattern
      def pattern(wrapper_options = nil)
        input_html_options[:pattern] ||= pattern_source
        nil
      end

      private

      def pattern_source
        pattern = options[:pattern]
        if pattern.is_a?(String)
          pattern
        elsif (pattern_validator = find_pattern_validator) && (with = pattern_validator.options[:with])
          evaluate_format_validator_option(with).source
        end
      end

      def find_pattern_validator
        find_validator(:format)
      end

      def evaluate_format_validator_option(option)
        if option.respond_to?(:call)
          option.call(object)
        else
          option
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/components/pattern.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/components/pattern.rb
simple_form-3.4.0 lib/simple_form/components/pattern.rb
simple_form-3.3.1 lib/simple_form/components/pattern.rb
simple_form-3.3.0 lib/simple_form/components/pattern.rb
simple_form-3.2.1 lib/simple_form/components/pattern.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/simple_form-3.2.0/lib/simple_form/components/pattern.rb
simple_form-3.2.0 lib/simple_form/components/pattern.rb
simple_form-3.1.1 lib/simple_form/components/pattern.rb
simple_form-3.1.0 lib/simple_form/components/pattern.rb
simple_form-3.1.0.rc2 lib/simple_form/components/pattern.rb
simple_form-3.1.0.rc1 lib/simple_form/components/pattern.rb