Sha256: feef8a869457ecabe0ca0ca92ad16affbfc8b5123a131572bc9a065c56961d7a

Contents?: true

Size: 803 Bytes

Versions: 7

Compression:

Stored size: 803 Bytes

Contents

# frozen_string_literal: true

require_relative '../reference'

# Reference attribute type for has_one
module LedgerSync
  class ResourceAttribute
    class Reference
      class One < Reference
        module Mixin
          def self.included(base)
            base.extend(ClassMethods)
          end

          module ClassMethods
            def references_one(name, to:)
              resource_attribute = ResourceAttribute::Reference::One.new(name: name, to: to)
              resource_attributes.add resource_attribute
              _define_attribute_methods(name)
            end
          end
        end

        def initialize(name:, to:)
          super(
            name: name,
            type: Type::ReferenceOne.new(resource_class: to)
          )
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ledger_sync-1.3.4 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.3.3 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.3.2 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.3.1 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.1.3 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.1.2 lib/ledger_sync/resource_attribute/reference/one.rb
ledger_sync-1.1.1 lib/ledger_sync/resource_attribute/reference/one.rb