Sha256: 5413342679d2d828e3a7a883fb14fb5209ea917ae99c90381f3496204d3436ba

Contents?: true

Size: 732 Bytes

Versions: 7

Compression:

Stored size: 732 Bytes

Contents

# @provides MotionKit::ConstraintsTarget
module MotionKit
  class ConstraintsTarget
    attr :view

    def initialize(view)
      @view = view
      @constraints = []
    end

    def add_constraints(constraints)
      @constraints.concat(constraints)
    end

    def ==(value)
      if value.is_a?(ConstraintsTarget)
        super
      else
        @view == value
      end
    end

    def apply_all_constraints(layout, target)
      @constraints.map do |mk_constraint|
        mk_constraint.resolve_all(layout, target).map do |constraint|
          if mk_constraint.active
            mk_constraint.common_ancestor.addConstraint(constraint)
          end
          constraint
        end
      end.flatten
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-1.1.0 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-1.0.3 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-1.0.2 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-1.0.1 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-1.0.0 lib/motion-kit-cocoa/constraints/constraints_target.rb
motion-kit-0.18.0 lib/motion-kit-cocoa/constraints/constraints_target.rb