Sha256: 18f50954a42b9a029a27eae52bcb9f7f8ec2447400beb67985a09687501748c6
Contents?: true
Size: 604 Bytes
Versions: 2
Compression:
Stored size: 604 Bytes
Contents
module Alba # Base class for `One` and `Many` # Child class should implement `to_hash` method class Association def initialize(name:, condition: nil, resource: nil, &block) @name = name @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 end private def resource_class klass = Class.new klass.include(Alba::Resource) klass.class_eval(&@block) klass end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alba-0.11.0 | lib/alba/association.rb |
alba-0.10.2 | lib/alba/association.rb |