lib/alba/association.rb in alba-0.9.0 vs lib/alba/association.rb in alba-0.10.0

- old
+ new

@@ -1,12 +1,13 @@ module Alba # Base class for `One` and `Many` # Child class should implement `to_hash` method class Association - def initialize(name:, resource: nil, &block) + def initialize(name:, condition: nil, resource: nil, &block) @name = name - @resource = resource + @condition = condition @block = block + @resource = resource || resource_class raise ArgumentError, 'resource or block is required' if @resource.nil? && @block.nil? end def to_hash :not_implemented