Sha256: 733397b9c143306ccb3763901e0fe10bc65a34d02e11095fe3afd55fa891e9a1

Contents?: true

Size: 577 Bytes

Versions: 20

Compression:

Stored size: 577 Bytes

Contents

module AngularSprinkles
  class ModelDecorator < SimpleDelegator
    def initialize(args)
      @key = args.fetch(:key)
      @json_wrapper = args.fetch(:json_wrapper)
      @object_wrapper = args.fetch(:object_wrapper)
      @object = args.fetch(:object)

      super(@object)
    end

    def bind(attribute = nil)
      @object_wrapper.new(@key, attribute, @json_wrapper)
    end

    ##
    # Rails uses #class as a part of #form_for to create labels.
    # Delegate this method to the model class to prevent this issue.
    def class
      @object.class
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
angular_sprinkles-0.3.3 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.3.2 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.3.1 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.3.0 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.14 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.13 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.12 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.11 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.10 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.9 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.8 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.7 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.6 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.5 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.4 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.3 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.2 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.1 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.2.0 lib/angular_sprinkles/model_decorator.rb
angular_sprinkles-0.1.1 lib/angular_sprinkles/model_decorator.rb