Sha256: 353845b4d9c15fca50ec1bb41159845caa90d7f9260ead3e98475d7cbabbf533

Contents?: true

Size: 486 Bytes

Versions: 6

Compression:

Stored size: 486 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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lhs-15.3.3 lib/lhs/concerns/record/relations.rb
lhs-15.3.3.pre.fixoptions.1 lib/lhs/concerns/record/relations.rb
lhs-15.3.2 lib/lhs/concerns/record/relations.rb
lhs-15.3.1 lib/lhs/concerns/record/relations.rb
lhs-15.3.1.pre.fixlhc.1 lib/lhs/concerns/record/relations.rb
lhs-15.3.0 lib/lhs/concerns/record/relations.rb