Skip to content

Commit

Permalink
Add ability to read attributes and add default for them to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-hill committed Dec 21, 2023
1 parent a7d478b commit 9e7319c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/testing_record/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def caching(option)
define_singleton_method(cache_name) { instance_variable_get(ivar_name) }
end

def create(attributes)
def create(attributes = {})
new(attributes).tap do |entity|
add_to_cache(entity) if respond_to?(cache_name)
end
Expand Down Expand Up @@ -47,6 +47,8 @@ def ivar_name
end
end

attr_reader :attributes

def initialize(attributes)
@attributes = attributes
end
Expand Down

0 comments on commit 9e7319c

Please sign in to comment.