lib/hanami/repository.rb in hanami-model-1.0.0.beta1 vs lib/hanami/repository.rb in hanami-model-1.0.0.beta2

- old
+ new

@@ -272,13 +272,17 @@ define_associations end # @since 0.7.0 # @api private - def self.inherited(klass) # rubocop:disable Metrics/MethodLength + # + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize + def self.inherited(klass) klass.class_eval do include Utils::ClassAttribute + auto_struct true class_attribute :entity class_attribute :entity_name self.entity_name = Model::EntityName.new(name) @@ -290,10 +294,12 @@ prepend Commands end Hanami::Model.repositories << klass end + # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/MethodLength # Extend commands from ROM::Repository with error management # # @since 0.7.0 module Commands @@ -417,11 +423,11 @@ # @since 0.7.0 # # @example # UserRepository.new.first def first - root.as(:entity).first + root.as(:entity).limit(1).one end # Returns the last record for the relation # # @return [Hanami::Entity,NilClass] last entity, if any @@ -429,10 +435,10 @@ # @since 0.7.0 # # @example # UserRepository.new.last def last - root.order(Model::Sql.desc(root.primary_key)).as(:entity).first + root.as(:entity).limit(1).reverse.one end # Deletes all the records from the relation # # @since 0.7.0