Skip to content

Commit

Permalink
Block fix (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
darthjee committed Sep 7, 2022
1 parent 0990084 commit 0573078
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ a creation in case of missing the entry

Yard Documentation
-------------------
[https://www.rubydoc.info/gems/zyra/1.0.0](https://www.rubydoc.info/gems/zyra/1.0.0)
[https://www.rubydoc.info/gems/zyra/1.1.0](https://www.rubydoc.info/gems/zyra/1.1.0)

Installation
---------------
Expand Down
12 changes: 6 additions & 6 deletions lib/zyra/creator.rb
Expand Up @@ -24,10 +24,12 @@ def initialize(model_class, event_registry:)
#
# @return [Object] an instance of model class
def create(**attributes, &block)
model = build(**attributes, &block)
block ||= proc {}

model = build(**attributes)

event_registry.trigger(:create, model) do
model.tap(&:save)
model.tap(&:save).tap(&block)
end
end

Expand All @@ -39,10 +41,8 @@ def create(**attributes, &block)
# @param (see #create)
# @yield (see #create)
# @return (see #create)
def build(**attributes, &block)
block ||= proc {}

model_class.new(attributes).tap(&block).tap do |model|
def build(**attributes)
model_class.new(attributes).tap do |model|
event_registry.trigger(:build, model)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/zyra/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Zyra
VERSION = '1.0.0'
VERSION = '1.1.0'
end

0 comments on commit 0573078

Please sign in to comment.