lib/hanami/model/association.rb in hanami-model-1.0.4 vs lib/hanami/model/association.rb in hanami-model-1.1.0.beta1

- old
+ new

@@ -1,8 +1,10 @@ require 'rom-sql' -require 'hanami/model/associations/has_many' require 'hanami/model/associations/belongs_to' +require 'hanami/model/associations/has_many' +require 'hanami/model/associations/has_one' +require 'hanami/model/associations/many_to_many' module Hanami module Model # Association factory # @@ -20,18 +22,24 @@ # Translate ROM SQL associations into Hanami::Model associations # # @since 0.7.0 # @api private + # rubocop:disable Metrics/MethodLength def self.lookup(association) case association + when ROM::SQL::Association::ManyToMany + Associations::ManyToMany + when ROM::SQL::Association::OneToOne + Associations::HasOne when ROM::SQL::Association::OneToMany Associations::HasMany when ROM::SQL::Association::ManyToOne Associations::BelongsTo else raise "Unsupported association: #{association}" end end + # rubocop:enable Metrics/MethodLength end end end