Sha256: 6d83839e4abc85d74129db0a4b2ffe2f63675b86251c5e0a380948b1b3d0639c

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

module Alba
  # Base class for `One` and `Many`
  # Child class should implement `to_hash` method
  class Association
    def initialize(name:, condition: nil, resource: nil, &block)
      @name = name
      @condition = condition
      @block = block
      @resource = resource || resource_class
      raise ArgumentError, 'resource or block is required' if @resource.nil? && @block.nil?
    end

    def to_hash
      :not_implemented
    end

    private

    def resource_class
      klass = ::Alba::Resources::DefaultResource.dup
      klass.reset
      klass.class_eval(&@block)
      klass
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alba-0.10.0 lib/alba/association.rb