Sha256: ab6f502ef9cb895e6f0b891a0321dc74663848221aa46a2def84d9dc326e9943

Contents?: true

Size: 516 Bytes

Versions: 15

Compression:

Stored size: 516 Bytes

Contents

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

15 entries across 15 versions & 1 rubygems

Version Path
lhs-16.1.5 lib/lhs/concerns/record/relations.rb
lhs-16.1.4 lib/lhs/concerns/record/relations.rb
lhs-16.1.3 lib/lhs/concerns/record/relations.rb
lhs-16.1.2 lib/lhs/concerns/record/relations.rb
lhs-16.1.1 lib/lhs/concerns/record/relations.rb
lhs-16.1.0 lib/lhs/concerns/record/relations.rb
lhs-16.0.1 lib/lhs/concerns/record/relations.rb
lhs-16.0.0 lib/lhs/concerns/record/relations.rb
lhs-15.7.0 lib/lhs/concerns/record/relations.rb
lhs-15.6.1 lib/lhs/concerns/record/relations.rb
lhs-15.6.0 lib/lhs/concerns/record/relations.rb
lhs-15.5.1 lib/lhs/concerns/record/relations.rb
lhs-15.5.0 lib/lhs/concerns/record/relations.rb
lhs-15.4.1 lib/lhs/concerns/record/relations.rb
lhs-15.4.0 lib/lhs/concerns/record/relations.rb