Sha256: c0cae168b3c56ab6d345de865bcebd76f5420e6b25ad9e3194353f01f4051847

Contents?: true

Size: 547 Bytes

Versions: 76

Compression:

Stored size: 547 Bytes

Contents

# frozen_string_literal: true

require 'active_support'
require 'active_support/core_ext/class/attribute'

class LHS::Record

  module Relations
    extend ActiveSupport::Concern

    included do
      class_attribute :_relations
      self._relations = {}
    end

    module ClassMethods
      def has_many(*options)
        name = options[0]
        options = options[1] || {}
        _relations[name] = { record_class_name: options.fetch(:class_name, name.to_s.singularize.classify) }
      end

      alias has_one has_many
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lhs-26.2.0 lib/lhs/concerns/record/relations.rb
lhs-26.1.0 lib/lhs/concerns/record/relations.rb
lhs-26.0.1 lib/lhs/concerns/record/relations.rb
lhs-26.0.0 lib/lhs/concerns/record/relations.rb
lhs-25.2.0 lib/lhs/concerns/record/relations.rb
lhs-25.1.0 lib/lhs/concerns/record/relations.rb
lhs-25.0.4 lib/lhs/concerns/record/relations.rb
lhs-25.0.3 lib/lhs/concerns/record/relations.rb
lhs-25.0.2 lib/lhs/concerns/record/relations.rb
lhs-25.0.1 lib/lhs/concerns/record/relations.rb
lhs-25.0.0 lib/lhs/concerns/record/relations.rb
lhs-24.1.2 lib/lhs/concerns/record/relations.rb
lhs-24.1.1 lib/lhs/concerns/record/relations.rb
lhs-24.1.0 lib/lhs/concerns/record/relations.rb
lhs-24.1.0.pre.2 lib/lhs/concerns/record/relations.rb
lhs-24.1.0.pre.1 lib/lhs/concerns/record/relations.rb
lhs-24.0.0 lib/lhs/concerns/record/relations.rb
lhs-23.0.2 lib/lhs/concerns/record/relations.rb
lhs-23.0.1 lib/lhs/concerns/record/relations.rb
lhs-23.0.0 lib/lhs/concerns/record/relations.rb