Sha256: e363113c91935306d95a8dcd4e1e726776b0ed0ce362e435f9c054f9d1a362db

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

class SuperAuth::Permission < Sequel::Model(:super_auth_permissions)
  one_to_many :edges

  dataset_module do
    def with_edges
      join(:super_auth_edges, permission_id: :id).select_all(:super_auth_permissions)
    end

    def with_roles
    with_edges.join(Role.from(Role.trees).as(:roles), id: :role_id).select(
        Sequel[:super_auth_permissions][:id].as(:id),
        Sequel[:super_auth_permissions][:id].as(:permission_id),
        Sequel[:roles][:id].as(:role_id),
        Sequel[:super_auth_permissions][:name].as(:permission_name),
        Sequel[:roles][:name].as(:role_name),
        Sequel[:super_auth_edges][:id].as(:edge_id),
        Sequel[:super_auth_edges][:permission_id].as(:edge_permission_id),
        Sequel[:super_auth_edges][:group_id].as(:edge_group_id),
        Sequel[:super_auth_edges][:user_id].as(:edge_user_id),
        Sequel[:super_auth_edges][:role_id].as(:edge_role_id),
        :role_path,
        :role_name_path,
        :parent_id
      )
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
super_auth-0.1.4 lib/super_auth/permission.rb