Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Aug 7, 2022
2 parents 21dd98d + 400e17f commit f6cbfa7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Relationships.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,32 @@ function Relationship(r1::Type{T}, r2::Type{R}; context::Module = @__MODULE__)::
getfield(context, Symbol(relationship_name(r1, r2)))
end

"""
Relationship!(r1::T, r2::R; context::Module)::AbstractModel where {T<:AbstractModel, R<:AbstractModel}
Relationship takes two AbstractModel types and
# Examples
```julia
julia> Base.@kwdef mutable struct Role <: AbstractModel
id::DbId = DbId()
name::String = ""
end
julia> Role(name::Union{String,Symbol}) = Role(name = string(name))
julia> Base.@kwdef mutable struct Permission <: AbstractModel
id::DbId = DbId()
name::String = ""
end
julia> Permission(name::Union{String,Symbol}) = Permission(name = string(name))
julia> Relationship!(user, role)
julia> isrelated(role, permission)
```
"""
function Relationship!(r1::T, r2::R; context::Module = @__MODULE__)::AbstractModel where {T<:AbstractModel, R<:AbstractModel}
relationship = Relationship(typeof(r1), typeof(r2); context = context)

Expand Down

2 comments on commit f6cbfa7

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65821

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.5.0 -m "<description of version>" f6cbfa755268896c43998ace3b22825f94e9cc7c
git push origin v2.5.0

Please sign in to comment.