Sha256: 9836a6b7f08cfa2aee27ce50b03abaf65dd6ddeba5e9a69470fb8a93dc08c3dc

Contents?: true

Size: 679 Bytes

Versions: 16

Compression:

Stored size: 679 Bytes

Contents

module AngularSprinkles
  class FormBinder
    class Default < Base
      private

      def augment_args
        binding = { "ng-model" => @attribute_binding }

        @args.tap do |args|
          # Assume that optional params default to {}
          # This is a safe assumption for all helpers except check_box
          (non_block_parameter_count - args.count).times { args.push({}) }

          # The last argument is always the one where ng-model should be appended
          args.last.reverse_merge!(binding)
        end
      end

      def non_block_parameter_count
        @method.parameters.count { |parameter| parameter.first != :block }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
angular_sprinkles-0.3.3 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.3.2 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.3.1 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.3.0 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.14 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.13 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.12 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.11 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.10 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.9 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.8 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.7 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.6 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.5 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.4 lib/angular_sprinkles/form_binder/default.rb
angular_sprinkles-0.2.3 lib/angular_sprinkles/form_binder/default.rb