Sha256: fe1733a5d1d6cd2c33c9e77f81acf7d5e67a1dea94c80a12b3dfdd38741488ab
Contents?: true
Size: 1.1 KB
Versions: 19
Compression:
Stored size: 1.1 KB
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: nil) to ||= begin require "#{inferred_config.root_path}/resources/#{name}" inferred_config.client_class.resources[name] end resource_attribute = ResourceAttribute::Reference::One.new( name: name, resource_class: self, to: to ) resource_attributes.add resource_attribute _define_attribute_methods(name) end end end def initialize(args = {}) to = args.fetch(:to) super( args.except(:to).merge( type: Type::ReferenceOne.new(resource_class: to) ) ) end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems