Sha256: aa9aab50a8d5ed3735337075c3d0d87b5a64acecc65f3640b0d48d4162aaf82e

Contents?: true

Size: 875 Bytes

Versions: 3

Compression:

Stored size: 875 Bytes

Contents

#
# Reproduced from https://github.com/rails/rails/pull/230/files for Association support
#
module ActiveResource::Associations::Builder
  class Association #:nodoc:

    # providing a Class-Variable, which will have a differend store of subclasses
    class_attribute :valid_options
    self.valid_options = [:class_name]

    # would identify subclasses of association
    class_attribute :macro

    attr_reader :model, :name, :options, :klass

    def self.build(model, name, options)
      new(model, name, options).build
    end

    def initialize(model, name, options)
      @model, @name, @options = model, name, options
    end

    def build
      validate_options
      reflection = model.create_reflection(self.class.macro, name, options)
    end

    private

    def validate_options
      options.assert_valid_keys(self.class.valid_options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openshift-origin-console-1.3.4 lib/active_resource/associations/builder/association.rb
openshift-origin-console-1.3.3 lib/active_resource/associations/builder/association.rb
openshift-origin-console-1.3.2 lib/active_resource/associations/builder/association.rb